-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2aa5eb2
Showing
14 changed files
with
1,117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# JetBrains IntelliJ | ||
target/ | ||
.idea/ | ||
LevelledMobs.iml | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
# Eclipse | ||
.classpath | ||
.project | ||
/.settings | ||
/.idea/ | ||
.idea/jarRepositories.xml | ||
.idea/discord.xml | ||
|
||
# macOS | ||
._.git | ||
.DS_Store |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module version="4"> | ||
<component name="FacetManager"> | ||
<facet type="minecraft" name="Minecraft"> | ||
<configuration> | ||
<autoDetectTypes> | ||
<platformType>PAPER</platformType> | ||
<platformType>ADVENTURE</platformType> | ||
</autoDetectTypes> | ||
</configuration> | ||
</facet> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# LM_Items | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>me.stumper66</groupId> | ||
<artifactId>LM_Items</artifactId> | ||
<version>0.9</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>LM_Items</name> | ||
<description>Allows custom items in custom drops for LevelledMobs</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
</properties> | ||
|
||
<build> | ||
<defaultGoal>clean package</defaultGoal> | ||
<sourceDirectory>src</sourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.3.0</version> | ||
<configuration> | ||
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation> | ||
<relocations> | ||
<relocation> | ||
<pattern>co.aikar.commands</pattern> | ||
<shadedPattern>me.stumper66.lm_items.acf</shadedPattern> | ||
</relocation> | ||
<relocation> | ||
<pattern>co.aikar.locales</pattern> | ||
<shadedPattern>me.stumper66.lm_items.locales</shadedPattern> | ||
</relocation> | ||
</relocations> | ||
<filters> | ||
<filter> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>META-INF/MANIFEST.MF</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
<minimizeJar>true</minimizeJar> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<createDependencyReducedPom>true</createDependencyReducedPom> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
<resources> | ||
<resource> | ||
<directory>src/me/stumper66/lm_items/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>papermc</id> | ||
<url>https://papermc.io/repo/repository/maven-public/</url> | ||
</repository> | ||
<repository> | ||
<id>spigotmc-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.papermc.paper</groupId> | ||
<artifactId>paper-api</artifactId> | ||
<version>1.18.2-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>nomaven</groupId> | ||
<artifactId>ExecutableItems</artifactId> | ||
<version>4.2.0.7</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>nomaven</groupId> | ||
<artifactId>SCore</artifactId> | ||
<version>1.7.0.7</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>nomaven</groupId> | ||
<artifactId>CustomCrafting</artifactId> | ||
<version>3.16.3.3</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>nomaven</groupId> | ||
<artifactId>WolfyUtils</artifactId> | ||
<version>4.16.1.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>nomaven</groupId> | ||
<artifactId>MMOItems</artifactId> | ||
<version>6.7.3</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>nomaven</groupId> | ||
<artifactId>MythicLib</artifactId> | ||
<version>1.0.19</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package me.stumper66.lm_items; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.TabCompleter; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
@SuppressWarnings("BooleanMethodIsAlwaysInverted") | ||
public class Commands implements CommandExecutor, TabCompleter { | ||
public Commands(final @NotNull LM_Items main){ | ||
this.main = main; | ||
} | ||
|
||
private final LM_Items main; | ||
private CommandSender sender; | ||
|
||
public boolean onCommand(@NotNull final CommandSender sender, final @NotNull Command command, final @NotNull String label, final String @NotNull [] args) { | ||
this.sender = sender; | ||
Utils.logger.info("args len: " + args.length); | ||
if (!hasPermissions(null)) return true; | ||
|
||
if (args.length == 0){ | ||
showSyntax(); | ||
return true; | ||
} | ||
|
||
switch (args[0].toLowerCase()){ | ||
case "info": | ||
showInfo(); | ||
break; | ||
case "installed_plugins": | ||
showInstalledPlugins(); | ||
break; | ||
case "supported_plugins": | ||
showSupportedPlugins(); | ||
break; | ||
default: | ||
showSyntax(); | ||
break; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private boolean hasPermissions(final @Nullable String perm){ | ||
if (sender.hasPermission("lm_items" + (perm == null ? "" : "." + perm))) | ||
return true; | ||
else { | ||
sender.sendMessage("You don't have permissions for this command"); | ||
return false; | ||
} | ||
} | ||
|
||
public void showSyntax() { | ||
sender.sendMessage("Usage: info | installed_plugins | supported_plugins"); | ||
} | ||
|
||
private void showInfo(){ | ||
if (!hasPermissions("info")) return; | ||
|
||
sender.sendMessage("LM_Items, version " + main.getDescription().getVersion() + System.lineSeparator() + | ||
"Created by stumper66, for use with LevelledMobs"); | ||
} | ||
|
||
private void showInstalledPlugins(){ | ||
final StringBuilder sb = new StringBuilder(); | ||
for (final String plugin : main.supportedPlugins.keySet()){ | ||
final ItemsAPI itemsAPI = main.supportedPlugins.get(plugin); | ||
|
||
if (sb.length() > 0) sb.append(", "); | ||
if (itemsAPI.getIsInstalled()) sb.append(plugin); | ||
} | ||
|
||
if (sb.length() > 0) | ||
sender.sendMessage("Installed plugins: " + sb); | ||
else | ||
sender.sendMessage("There are now installed plugins that are supported"); | ||
} | ||
private void showSupportedPlugins(){ | ||
final StringBuilder sb = new StringBuilder(); | ||
|
||
for (final String pluginName : main.supportedPluginNames){ | ||
if (sb.length() > 0) sb.append(", "); | ||
sb.append(pluginName); | ||
} | ||
|
||
sender.sendMessage("Supported plugin: " + sb); | ||
} | ||
|
||
@Override | ||
public @Nullable List<String> onTabComplete(final @NotNull CommandSender sender, final @NotNull Command command, final @NotNull String label, final @NotNull String @NotNull [] args){ | ||
if (args.length <= 1) | ||
return List.of("info", "installed_plugins", "supported_plugins"); | ||
|
||
return Collections.emptyList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package me.stumper66.lm_items; | ||
|
||
import org.bukkit.inventory.ItemStack; | ||
|
||
public class GetItemResult { | ||
public boolean pluginIsInstalled; | ||
public ItemStack itemStack; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package me.stumper66.lm_items; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
|
||
public interface ItemsAPI { | ||
boolean getIsInstalled(); | ||
|
||
@NotNull GetItemResult getItem(final @Nullable String type, final @NotNull String itemId); | ||
|
||
@NotNull List<String> getItemTypes(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package me.stumper66.lm_items; | ||
|
||
import me.stumper66.lm_items.plugins.MMOItems; | ||
import org.bukkit.command.PluginCommand; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.TreeMap; | ||
|
||
public class LM_Items extends JavaPlugin implements LM_Items_API { | ||
public LM_Items(){ | ||
plugin = this; | ||
this.supportedPlugins = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); | ||
this.supportedPluginNames = List.of("MMOItems"); | ||
} | ||
|
||
public static LM_Items plugin; | ||
final Map<String, ItemsAPI> supportedPlugins; | ||
final List<String> supportedPluginNames; | ||
|
||
@Override | ||
public void onEnable() { | ||
for (int i = 0; i < this.supportedPluginNames.size(); i++) { | ||
switch (i){ | ||
case 0: | ||
this.supportedPlugins.put(this.supportedPluginNames.get(i), new MMOItems()); | ||
break; | ||
} | ||
} | ||
|
||
final PluginCommand cmd = getCommand("lm_items"); | ||
if (cmd == null) | ||
Utils.logger.warning("Command &b/lm_items&7 is unavailable, is it not registered in plugin.yml?"); | ||
else | ||
cmd.setExecutor(new Commands(this)); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
|
||
} | ||
|
||
public boolean doesSupportPlugin(@NotNull final String pluginName){ | ||
return this.supportedPlugins.containsKey(pluginName); | ||
} | ||
|
||
public @Nullable ItemsAPI getItemAPIForPlugin(final @NotNull String pluginName) { | ||
return this.supportedPlugins.get(pluginName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package me.stumper66.lm_items; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public interface LM_Items_API { | ||
boolean doesSupportPlugin(@NotNull final String pluginName); | ||
|
||
@Nullable ItemsAPI getItemAPIForPlugin(final @NotNull String pluginName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package me.stumper66.lm_items; | ||
|
||
import org.bukkit.Bukkit; | ||
|
||
import java.util.logging.Logger; | ||
|
||
public class Utils { | ||
public static final Logger logger = Bukkit.getLogger(); | ||
} |
Oops, something went wrong.
set to
*.iml
instead :)