Fix compilation and add PlotSquared v5 support

This commit is contained in:
Lennart ten Wolde 2020-05-20 17:49:56 +02:00
parent 814827beaa
commit 4b7714d2f0
8 changed files with 176 additions and 258 deletions

View File

@ -6,6 +6,7 @@
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="Marriage" />
<module name="marriage2" />
</profile>
</annotationProcessing>

View File

@ -2,5 +2,7 @@
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>

View File

@ -2,122 +2,46 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="f053dcdb-5af2-49cb-86ae-0ae3e6974408" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/listeners/V5PlotSquaredListener.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/encodings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/encodings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/latest_version.json" beforeDir="false" afterPath="$PROJECT_DIR$/latest_version.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/changelog.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/changelog.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/internal/MarriageCore.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/internal/MarriageCore.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/listeners/PlotSquaredListener.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/listeners/LegacyPlotSquaredListener.java" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/out/" />
<ignored path="$PROJECT_DIR$/target/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf />
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/.gitignore" />
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/latest_version.json" />
<option value="$PROJECT_DIR$/src/main/resources/changelog.json" />
</list>
</option>
</component>
<component name="MavenImportPreferences">
<option name="importingSettings">
<MavenImportingSettings>
<option name="importAutomatically" value="true" />
</MavenImportingSettings>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="150" />
<option name="width" value="1840" />
<option name="height" value="789" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="marriage2" type="b2602c69:ProjectViewProjectNode" />
<item name="Marriage" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="marriage2" type="b2602c69:ProjectViewProjectNode" />
<item name="Marriage" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="marriage2" type="b2602c69:ProjectViewProjectNode" />
<item name="Marriage" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="marriage2" type="b2602c69:ProjectViewProjectNode" />
<item name="Marriage" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="marriage2" type="b2602c69:ProjectViewProjectNode" />
<item name="Marriage" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="marriage2" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="marriage2" type="b2602c69:ProjectViewProjectNode" />
<item name="Marriage" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="resources" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="PackagesPane" />
</panes>
<component name="ProjectId" id="1cB29FyB0u0N1sQBBgxCRoyoLmg" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
@ -127,12 +51,10 @@
<option name="presentableId" value="Default" />
<updated>1556527215114</updated>
<workItem from="1556527218811" duration="1549000" />
<workItem from="1589987513901" duration="2087000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="1549000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
<is-autoscroll-to-source value="true" />
@ -142,97 +64,38 @@
<is-autoscroll-to-source value="true" />
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="0" y="0" width="1920" height="1080" extended-state="6" />
<layout>
<window_info id="Designer" />
<window_info id="Favorites" side_tool="true" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.2497332" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Docker" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" />
<window_info anchor="bottom" id="Version Control" weight="0.32944915" />
<window_info active="true" anchor="bottom" id="Terminal" visible="true" weight="0.32944915" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.32944915" />
<window_info anchor="right" id="Maven" />
<window_info anchor="right" id="Palette&#9;" />
<window_info anchor="right" id="Database" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
<option name="version" value="2" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State>
<option name="RECENTLY_FILTERED_USER_GROUPS">
<collection />
</option>
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
<collection />
</option>
<option name="COLUMN_ORDER">
<list>
<option value="0" />
<option value="1" />
<option value="2" />
<option value="3" />
</list>
</option>
</State>
<State />
</value>
</entry>
</map>
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="22" column="5" selection-start-line="22" selection-start-column="5" selection-end-line="22" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="19" selection-start-line="6" selection-start-column="19" selection-end-line="6" selection-end-column="19" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/latest_version.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" column="96" lean-forward="true" selection-start-line="4" selection-start-column="96" selection-end-line="4" selection-end-column="96" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/resources/changelog.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<caret line="3" column="3" lean-forward="true" selection-start-line="3" selection-start-column="3" selection-end-line="3" selection-end-column="3" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/resources/plugin.yml">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/main/resources/updater.txt">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<component name="WindowStateProjectService">
<state x="1060" y="477" width="502" height="520" key="FileChooserDialogImpl" timestamp="1589988962406">
<screen x="72" y="28" width="2488" height="1412" />
</state>
<state x="1060" y="477" width="502" height="520" key="FileChooserDialogImpl/72.28.2488.1412/2560.0.2560.1440@72.28.2488.1412" timestamp="1589988962406" />
<state x="1007" y="473" width="652" height="522" key="find.popup" timestamp="1589988148983">
<screen x="72" y="28" width="2488" height="1412" />
</state>
<state x="1007" y="473" width="652" height="522" key="find.popup/72.28.2488.1412/2560.0.2560.1440@72.28.2488.1412" timestamp="1589988148983" />
<state x="1072" y="480" width="477" height="514" key="refactoring.ChangeSignatureDialog" timestamp="1589988637564">
<screen x="72" y="28" width="2488" height="1412" />
</state>
<state x="1072" y="480" width="477" height="514" key="refactoring.ChangeSignatureDialog/72.28.2488.1412/2560.0.2560.1440@72.28.2488.1412" timestamp="1589988637564" />
<state x="979" y="350" width="672" height="678" key="search.everywhere.popup" timestamp="1589989339828">
<screen x="72" y="28" width="2488" height="1412" />
</state>
<state x="979" y="350" width="672" height="678" key="search.everywhere.popup/72.28.2488.1412/2560.0.2560.1440@72.28.2488.1412" timestamp="1589989339828" />
</component>
<component name="masterDetails">
<states>

115
pom.xml
View File

@ -19,13 +19,25 @@
<id>md5-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<!-- Vault -->
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<!-- CodeMC -->
<repository>
<id>lenis0012-repo</id>
<url>http://ci.lenis0012.com/plugin/repository/everything/</url>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
<!-- WorldEdit -->
<repository>
<id>enginehub</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
<!-- PlotSquared -->
<repository>
<id>IntellectualSites</id>
<url>https://mvn.intellectualsites.com/content/groups/public/</url>
</repository>
</repositories>
@ -36,17 +48,10 @@
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.plotsquared.bukkit</groupId>
<artifactId>PlotSquared</artifactId>
<version>3.3.3</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/PlotSquared.jar</systemPath>
</dependency>
<dependency>
<groupId>com.lenis0012.bukkit</groupId>
<artifactId>lenisutils</artifactId>
<version>1.0</version>
<version>1.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
@ -58,7 +63,22 @@
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.5</version>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<!-- PlotSquared Legacy (before v4)-->
<dependency>
<groupId>com.plotsquared.bukkit</groupId>
<artifactId>PlotSquared</artifactId>
<version>3.3.3</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/PlotSquared.jar</systemPath>
</dependency>
<!-- PlotSquared v5 -->
<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared</artifactId>
<version>5.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
@ -81,35 +101,7 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${project.name}-Bukkit-${project.version}</finalName>
<artifactSet>
<includes>
<include>com.lenis0012.updater:updater-api</include>
<include>com.lenis0012.updater:updater-bukkit</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.lenis0012.updater</pattern>
<shadedPattern>com.lenis0012.bukkit.marriage2.libs.updater</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<finalName>${project.name}-Bukkit-${project.version}</finalName>
</build>
</profile>
<profile>
@ -129,35 +121,7 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${project.name}-Spigot-${project.version}</finalName>
<artifactSet>
<includes>
<include>com.lenis0012.updater:updater-api</include>
<include>com.lenis0012.updater:updater-spigot</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.lenis0012.updater</pattern>
<shadedPattern>com.lenis0012.bukkit.marriage2.libs.updater</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<finalName>${project.name}-Spigot-${project.version}</finalName>
</build>
</profile>
</profiles>
@ -183,7 +147,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
@ -193,7 +157,7 @@
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.3</version>
<executions>
<execution>
<id>general</id>
@ -203,16 +167,15 @@
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>com.lenis0012.bukkit:lenisutils</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.lenis0012.pluginutils</pattern>
<shadedPattern>com.lenis0012.bukkit.marriage2.libs.pluginutils</shadedPattern>
</relocation>
<relocation>
<pattern>com.lenis0012.updater</pattern>
<shadedPattern>com.lenis0012.bukkit.marriage2.libs.updater</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>

View File

@ -89,10 +89,32 @@ public class MarriageCore extends MarriageBase {
if(Settings.PLOTSQUARED_AUTO_TRUST.value() && Bukkit.getPluginManager().isPluginEnabled("PlotSquared")) {
Plugin plotSquared = Bukkit.getPluginManager().getPlugin("PlotSquared");
getLogger().log(Level.INFO, "Hooking with PlotSquared v" + plotSquared.getDescription().getVersion());
register(new PlotSquaredListener());
hookPlotSquared();
}
}
private void hookPlotSquared() {
try {
getLogger().log(Level.INFO, "Attempting to hook with PlotSquared v5.");
Class.forName("com.plotsquared.core.api.PlotAPI");
register(new V5PlotSquaredListener());
getLogger().log(Level.INFO, "Success! Auto-trust has been enabled.");
return;
} catch (Exception e) {
}
try {
getLogger().log(Level.INFO, "Attempting to hook with PlotSquared legacy.");
Class.forName("com.intellectualcrafters.plot.PS");
register(new LegacyPlotSquaredListener());
getLogger().log(Level.INFO, "Success! Auto-trust has been enabled.");
return;
} catch (Exception e) {
}
getLogger().log(Level.WARNING, "Failed to hook with PlotSquared, please use v5 for full support.");
}
@Register(name = "commands", type = Register.Type.ENABLE)
public void registerCommands() {
register(
@ -115,9 +137,6 @@ public class MarriageCore extends MarriageBase {
CommandTeleport.class,
CommandUpdate.class
);
// for(Class<? extends Command> command : findClasses("com.lenis0012.bukkit.marriage2.commands", Command.class)) {
// register(command);
// }
}
@Register(name = "updater", type = Type.ENABLE, priority = 9)

View File

@ -1,6 +1,7 @@
package com.lenis0012.bukkit.marriage2.listeners;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.api.PlotAPI;
import com.intellectualcrafters.plot.object.Plot;
import com.lenis0012.bukkit.marriage2.MData;
import com.lenis0012.bukkit.marriage2.events.PlayerDivorceEvent;
@ -11,10 +12,10 @@ import org.bukkit.event.Listener;
import java.util.UUID;
public class PlotSquaredListener implements Listener {
public class LegacyPlotSquaredListener implements Listener {
private final PS plotSquared;
public PlotSquaredListener() {
public LegacyPlotSquaredListener() {
this.plotSquared = PS.get();
}

View File

@ -0,0 +1,66 @@
package com.lenis0012.bukkit.marriage2.listeners;
import com.lenis0012.bukkit.marriage2.MData;
import com.lenis0012.bukkit.marriage2.events.PlayerDivorceEvent;
import com.lenis0012.bukkit.marriage2.events.PlayerMarryEvent;
import com.plotsquared.core.api.PlotAPI;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import java.util.UUID;
public class V5PlotSquaredListener implements Listener {
private final PlotAPI plotSquared;
public V5PlotSquaredListener() {
this.plotSquared = new PlotAPI();
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMarry(PlayerMarryEvent event) {
final UUID player = event.getRequesing().getUniqueId();
final UUID partner = event.getRequested().getUniqueId();
PlotPlayer plotPlayer = plotSquared.wrapPlayer(player);
PlotPlayer plotPartner = plotSquared.wrapPlayer(partner);
for(Plot plot : plotSquared.getPlayerPlots(plotPlayer)) {
if(plot.getTrusted().contains(partner)) {
continue;
}
plot.addTrusted(partner);
}
for(Plot plot : plotSquared.getPlayerPlots(plotPartner)) {
if(plot.getTrusted().contains(player)) {
continue;
}
plot.addTrusted(player);
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDivorce(PlayerDivorceEvent event) {
final MData marriage = event.getMarriage();
final UUID player = marriage.getPlayer1Id();
final UUID partner = marriage.getPllayer2Id();
PlotPlayer plotPlayer = plotSquared.wrapPlayer(player);
PlotPlayer plotPartner = plotSquared.wrapPlayer(partner);
for(Plot plot : plotSquared.getPlayerPlots(plotPlayer)) {
if(!plot.getTrusted().contains(partner)) {
continue;
}
plot.removeTrusted(partner);
}
for(Plot plot : plotSquared.getPlayerPlots(plotPartner)) {
if(!plot.getTrusted().contains(player)) {
continue;
}
plot.removeTrusted(player);
}
}
}