Initial Commit

Signed-off-by: Etzelia <etzelia@hotmail.com>
grief
Etzelia 2020-07-20 22:17:08 -05:00
commit f222ff3665
No known key found for this signature in database
GPG Key ID: 708511AE7ABC5314
11 changed files with 353 additions and 0 deletions

4
.gitignore vendored 100644
View File

@ -0,0 +1,4 @@
.idea/
*.iml
target/
dependency-reduced-pom.xml

7
LICENSE 100644
View File

@ -0,0 +1,7 @@
Copyright 2020 Etzelia
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1
README.md 100644
View File

@ -0,0 +1 @@
# OreAlert

135
pom.xml 100644
View File

@ -0,0 +1,135 @@
<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>xyz.etztech</groupId>
<artifactId>OreAlert</artifactId>
<!-- Version is used in plugin.yml -->
<version>0.0.1</version>
<packaging>jar</packaging>
<!-- Plugin Information -->
<!-- Name, Description, and URL are used in plugin.yml -->
<name>OreAlert</name>
<description>Keep track of mining and alert if needed.</description>
<url>https://git.etztech.xyz/Minecraft/OreAlert</url>
<developers>
<developer>
<name>EtzTech</name>
<url>http://www.etztech.xyz</url>
</developer>
</developers>
<properties>
<!-- Author and MainClass are used in plugin.yml -->
<author>EtzTech</author>
<mainClass>xyz.etztech.orealert.OreAlert</mainClass>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>xyz.etztech</groupId>
<artifactId>EtzCore</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>etztech-repo</id>
<url>http://repo.etztech.xyz</url>
</repository>
<repository>
<id>mvn-repo</id>
<url>https://mvnrepository.com/artifact/</url>
</repository>
<repository> <!-- This repo fixes issues with transitive dependencies -->
<id>jcenter</id>
<url>http://jcenter.bintray.com</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<defaultGoal>clean install</defaultGoal>
<resources>
<resource>
<directory>src/main/resources</directory>
<!-- Keeping filtering at true here reduces plugin.yml redundancy! -->
<filtering>true</filtering>
<includes>
<include>plugin.yml</include>
<include>config.yml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<!-- Keep filtering at false for other resources to prevent bad magic -->
<filtering>false</filtering>
<excludes>
<exclude>**/*.java</exclude>
<exclude>plugin.yml</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>xyz.etztech.orealert.OreAlert</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,9 @@
package xyz.etztech.orealert;
import net.md_5.bungee.api.ChatColor;
public class Color {
public static ChatColor ERROR = ChatColor.of("#f14668");
public static ChatColor INFO = ChatColor.of("#3298dc");
public static ChatColor PRIMARY = ChatColor.of("#3273dc");
}

View File

@ -0,0 +1,26 @@
package xyz.etztech.orealert;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.command.CommandSender;
public enum Lang {
NO_PERMISSION("You don't have permission to do that.", Color.ERROR),
UNKNOWN_COMMAND("This command wasn't recognized.", Color.ERROR),
PLUGIN_RELOADED("Plugin reloaded.", Color.INFO);
private final String message;
private final ChatColor color;
Lang(String message, ChatColor color) {
this.message = message;
this.color = color;
}
public void sms(CommandSender sender) {
TextComponent text = new TextComponent(this.message);
text.setColor(this.color);
sender.spigot().sendMessage(text);
}
}

View File

@ -0,0 +1,47 @@
package xyz.etztech.orealert;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import xyz.etztech.orealert.commands.MainCommand;
import xyz.etztech.orealert.listeners.BlockBreakListener;
import java.util.logging.Logger;
public class OreAlert extends JavaPlugin {
private static OreAlert instance;
public static FileConfiguration config;
private final Logger log = Logger.getLogger( "Minecraft" );
public void onEnable() {
instance = this;
saveDefaultConfig();
reloadConfig();
if (isEnabled()) {
new MainCommand(this);
new BlockBreakListener(this);
}
}
public void loadConfig() {
config = Bukkit.getPluginManager().getPlugin("OreAlert").getConfig();
}
@Override
public void reloadConfig() {
super.reloadConfig();
loadConfig();
}
public void log(String message) {
log.info( "[OreAlert]: " + message );
}
public static OreAlert getInstance() {
return instance;
}
}

View File

@ -0,0 +1,61 @@
package xyz.etztech.orealert.commands;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import xyz.etztech.orealert.Color;
import xyz.etztech.orealert.Lang;
import xyz.etztech.orealert.OreAlert;
public class MainCommand implements CommandExecutor {
OreAlert plugin;
public MainCommand(OreAlert plugin) {
this.plugin = plugin;
this.plugin.getCommand("orealert").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
if (!commandSender.hasPermission("orealert.admin")) {
Lang.NO_PERMISSION.sms(commandSender);
return true;
}
if (args.length == 0) {
help(commandSender);
} else {
switch (args[0]) {
case "help":
help(commandSender);
break;
case "reload":
reload(commandSender);
break;
default:
Lang.UNKNOWN_COMMAND.sms(commandSender);
break;
}
}
return true;
}
private void help(CommandSender commandSender) {
String version = Bukkit.getPluginManager().getPlugin("OreAlert").getDescription().getVersion();
BaseComponent[] message = new ComponentBuilder()
.append(String.format("===== OreAlert v%s =====", version)).color(Color.PRIMARY)
.append("\n/orealert help - Show this message").color(Color.INFO)
.append("\n/orealert reload - Reload the config").color(Color.INFO)
.create();
commandSender.spigot().sendMessage(message);
}
private void reload(CommandSender commandSender) {
this.plugin.reloadConfig();
Lang.PLUGIN_RELOADED.sms(commandSender);
}
}

View File

@ -0,0 +1,21 @@
package xyz.etztech.orealert.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import xyz.etztech.orealert.OreAlert;
public class BlockBreakListener implements Listener {
private final OreAlert plugin;
public BlockBreakListener(OreAlert plugin) {
this.plugin = plugin;
this.plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
}
}

View File

@ -0,0 +1,25 @@
# Global settings, for less arthritis
# How long until we purge a node strike, in minutes
purge: 30
# How many veins found within the above purge minutes to notify
start: 5
# After the initial alert, how many should be found in addition before more alerts?
each: 1
# After the initial alert, how many should be found in addition before more pings?
ping: 5
# Discord webhook
webhook: ''
# Only blocks listed here will be monitored
# Each of the above notify settings can be overridden per-block if needed
# Anything not overridden will default to the global setting
blocks:
-
material: 'diamond_ore'
name: 'Diamond Ore'
color: '#b9f2ff'
-
material: 'ancient_debris'
name: 'Ancient Debris'
color: '#933A16'
purge: 45

View File

@ -0,0 +1,17 @@
name: ${name}
version: ${version}
description: ${description}
author: ${author}
website: ${url}
main: ${mainClass}
api-version: 1.16
commands:
orealert:
description: Base command
permissions:
orealert.admin:
description: Ability to reload the plugin
default: op
orealert.alert:
description: Get alerts
default: op