-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
41 changed files
with
1,686 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,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="FacetManager"> | ||
<facet type="minecraft" name="Minecraft"> | ||
<configuration> | ||
<autoDetectTypes> | ||
<platformType>SPIGOT</platformType> | ||
</autoDetectTypes> | ||
</configuration> | ||
</facet> | ||
</component> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> | ||
<output url="file://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" /> | ||
<excludeFolder url="file://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:2.2.1" level="project" /> | ||
<orderEntry type="library" name="Maven: org.bstats:bstats-base:2.2.1" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.22" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-all:4.1.42.Final" level="project" /> | ||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.18" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" /> | ||
<orderEntry type="library" name="Maven: co.aikar:acf-paper:0.5.1-SNAPSHOT" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.11.1" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains:annotations:19.0.0" level="project" /> | ||
</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,125 @@ | ||
<?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.chrommob</groupId> | ||
<artifactId>MineStore</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>MineStore</name> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<source>${java.version}</source> | ||
<target>${java.version}</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.2.4</version> | ||
<configuration> | ||
<relocations> | ||
<relocation> | ||
<pattern>org.bstats</pattern> | ||
<!-- Replace this with your package! --> | ||
<shadedPattern>me.chrommob.minestore.util.bstats</shadedPattern> | ||
</relocation> | ||
</relocations> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<createDependencyReducedPom>false</createDependencyReducedPom> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>placeholderapi</id> | ||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url> | ||
</repository> | ||
<repository> | ||
<id>aikar</id> | ||
<url>https://repo.aikar.co/content/groups/aikar/</url> | ||
</repository> | ||
<repository> | ||
<id>spigotmc-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
<repository> | ||
<id>sonatype</id> | ||
<url>https://oss.sonatype.org/content/groups/public/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.bstats</groupId> | ||
<artifactId>bstats-bukkit</artifactId> | ||
<version>2.2.1</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.22</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.netty</groupId> | ||
<artifactId>netty-all</artifactId> | ||
<version>4.1.42.Final</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.8.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.12-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>co.aikar</groupId> | ||
<artifactId>acf-paper</artifactId> <!-- Don't forget to replace this --> | ||
<version>0.5.1-SNAPSHOT</version> <!-- Replace this as well --> | ||
</dependency> | ||
<dependency> | ||
<groupId>me.clip</groupId> | ||
<artifactId>placeholderapi</artifactId> | ||
<version>2.11.1</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,120 @@ | ||
package me.chrommob.minestore; | ||
|
||
import co.aikar.commands.PaperCommandManager; | ||
import io.netty.bootstrap.ServerBootstrap; | ||
import io.netty.channel.ChannelOption; | ||
import io.netty.channel.EventLoopGroup; | ||
import io.netty.channel.nio.NioEventLoopGroup; | ||
import io.netty.channel.socket.nio.NioServerSocketChannel; | ||
import me.chrommob.minestore.command.Buy; | ||
import me.chrommob.minestore.command.Reload; | ||
import me.chrommob.minestore.command.Store; | ||
import me.chrommob.minestore.data.Config; | ||
import me.chrommob.minestore.gui.Event; | ||
import me.chrommob.minestore.placeholders.PlaceholderHook; | ||
import me.chrommob.minestore.storage.PunishmentManager; | ||
import me.chrommob.minestore.listeners.JoinQuitListener; | ||
import me.chrommob.minestore.util.Mode; | ||
import me.chrommob.minestore.util.Runnable; | ||
import me.chrommob.minestore.websocket.Socket; | ||
import org.bstats.bukkit.Metrics; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.plugin.PluginManager; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public final class MineStore extends JavaPlugin { | ||
public static MineStore instance; | ||
Mode mode = Mode.WEBSOCKET; | ||
|
||
@Override | ||
public void onLoad() { | ||
saveDefaultConfig(); | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
Metrics metrics = new Metrics(this, 14043); | ||
dependencyCheck(); | ||
PluginManager plManager = Bukkit.getPluginManager(); | ||
instance = this; | ||
PaperCommandManager manager = new PaperCommandManager(this); | ||
manager.registerCommand(new Reload()); | ||
plManager.registerEvents(new JoinQuitListener(), this); | ||
plManager.registerEvents(new Event(this), this); | ||
PunishmentManager.create(); | ||
PunishmentManager.get(); | ||
loadConfig(); | ||
if (getConfig().getString("mode").equalsIgnoreCase("WEBSOCKET")) { | ||
mode = Mode.WEBSOCKET; | ||
} else { | ||
mode = Mode.WEBLISTENER; | ||
} | ||
Config.setStoreEnabled(getConfig().getBoolean("store-enabled")); | ||
Config.setPort(getConfig().getInt("port")); | ||
Config.setGuiEnabled(getConfig().getBoolean("gui-enabled")); | ||
if (mode == Mode.WEBSOCKET) { | ||
Runnable.runListener("NO"); | ||
try { | ||
NettyServer(Config.getPort()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} else { | ||
Runnable.runListener("web"); | ||
Bukkit.getLogger().info("[MineStore] Starting web listener..."); | ||
} | ||
if (Config.isGuiEnabled()) { | ||
manager.registerCommand(new Buy(this)); | ||
Bukkit.getLogger().info("[MineStore] Starting gui listener..."); | ||
} | ||
if (Config.isStoreEnabled()) { | ||
manager.registerCommand(new Store()); | ||
} | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
// Plugin shutdown logic | ||
} | ||
|
||
private void dependencyCheck() { | ||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") == null) { | ||
Bukkit.getLogger().info("[MineStore] PlaceholderAPI found!"); | ||
Config.setPlaceholderPresent(false); | ||
} else { | ||
Config.setPlaceholderPresent(true); | ||
new PlaceholderHook(this).register(); | ||
} | ||
} | ||
|
||
private void NettyServer(int port) throws Exception | ||
{ | ||
EventLoopGroup eventLoopGroup = new NioEventLoopGroup(); | ||
EventLoopGroup worker = new NioEventLoopGroup(); | ||
|
||
ServerBootstrap serverBootstrap = new ServerBootstrap(); | ||
getLogger().info("Starting Server at " + port); | ||
|
||
serverBootstrap.group(eventLoopGroup, worker) | ||
.channel(NioServerSocketChannel.class) | ||
.childHandler(new Socket()) | ||
.childOption(ChannelOption.SO_KEEPALIVE, true); | ||
|
||
serverBootstrap.bind(port).sync(); | ||
} | ||
|
||
public void loadConfig() { | ||
reloadConfig(); | ||
Config.setPassword(getConfig().getString("password")); | ||
Config.setApiUrl(getConfig().getString("store-api")); | ||
Config.setStoreMessage(getConfig().getString("store-message")); | ||
Config.setSecretKey(getConfig().getString("secret-key")); | ||
Config.setGuiName(getConfig().getString("settings.name")); | ||
Config.setPackageMessage(getConfig().getString("settings.message")); | ||
Config.setBuyUrl(getConfig().getString("settings.api-url")); | ||
Config.setItemName(getConfig().getString("format.item-name")); | ||
Config.setItemDescription(getConfig().getString("format.item-description")); | ||
Config.setItemPrice(getConfig().getString("format.item-price")); | ||
Config.setApiKey(getConfig().getInt("api-key")); | ||
} | ||
} |
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,30 @@ | ||
package me.chrommob.minestore.command; | ||
|
||
import co.aikar.commands.BaseCommand; | ||
import co.aikar.commands.annotation.CommandAlias; | ||
import co.aikar.commands.annotation.CommandPermission; | ||
import co.aikar.commands.annotation.Default; | ||
import co.aikar.commands.annotation.Subcommand; | ||
import me.chrommob.minestore.MineStore; | ||
import me.chrommob.minestore.gui.create.catGUI; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
@CommandAlias("buy") | ||
public class Buy extends BaseCommand { | ||
private MineStore plugin; | ||
public Buy(MineStore plugin) { | ||
this.plugin = plugin; | ||
} | ||
@Default | ||
@CommandPermission("ms.buy") | ||
private void onBuy(CommandSender sender) { | ||
if (!(sender instanceof Player)) { | ||
sender.sendMessage("§cYou must be a player to use this command."); | ||
return; | ||
} | ||
Player player = (Player) sender; | ||
catGUI gui = new catGUI(plugin); | ||
gui.openGUI(player); | ||
} | ||
} |
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,23 @@ | ||
package me.chrommob.minestore.command; | ||
|
||
import co.aikar.commands.BaseCommand; | ||
import co.aikar.commands.annotation.CommandAlias; | ||
import co.aikar.commands.annotation.CommandPermission; | ||
import co.aikar.commands.annotation.Subcommand; | ||
import me.chrommob.minestore.MineStore; | ||
import org.bukkit.command.CommandSender; | ||
|
||
@CommandAlias("MineStore|ms") | ||
public class Reload extends BaseCommand { | ||
@Subcommand("reload") | ||
@CommandPermission("ms.reload") | ||
private void onReload(CommandSender sender) { | ||
try { | ||
MineStore.instance.loadConfig(); | ||
sender.sendMessage("§aConfig reloaded! Be aware reloading doesn't reload the mode, websocket port, gui toggle and store toggle."); | ||
} catch (Exception e) { | ||
sender.sendMessage("§cAn error occurred while reloading the config."); | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
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,22 @@ | ||
package me.chrommob.minestore.command; | ||
|
||
import co.aikar.commands.BaseCommand; | ||
import co.aikar.commands.annotation.CommandAlias; | ||
import co.aikar.commands.annotation.CommandPermission; | ||
import co.aikar.commands.annotation.Default; | ||
import co.aikar.commands.annotation.Subcommand; | ||
import me.chrommob.minestore.MineStore; | ||
import me.chrommob.minestore.data.Config; | ||
import me.chrommob.minestore.gui.create.catGUI; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
@CommandAlias("store") | ||
public class Store extends BaseCommand { | ||
@Default | ||
@CommandPermission("ms.store") | ||
private void onBuy(CommandSender sender) { | ||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',Config.getStoreMessage())); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/me/chrommob/minestore/commandsend/Command.java
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,20 @@ | ||
package me.chrommob.minestore.commandsend; | ||
|
||
import org.bukkit.Bukkit; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
|
||
public class Command { | ||
public static HashMap<String, ArrayList<String>> runLater = new HashMap<>(); | ||
|
||
public static void online(String command) { | ||
Bukkit.getScheduler().runTask(Bukkit.getPluginManager().getPlugin("MineStore"), () -> { | ||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); | ||
}); | ||
} | ||
|
||
public static void offline(String username, String command) { | ||
Manager.add(username, command); | ||
} | ||
} |
Oops, something went wrong.