-
Notifications
You must be signed in to change notification settings - Fork 22
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 da06bc5
Showing
19 changed files
with
2,209 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,113 @@ | ||
# User-specific stuff | ||
.idea/ | ||
|
||
*.iml | ||
*.ipr | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
*~ | ||
|
||
# temporary files which can be created if a process still has a handle open of a deleted file | ||
.fuse_hidden* | ||
|
||
# KDE directory preferences | ||
.directory | ||
|
||
# Linux trash folder which might appear on any partition or disk | ||
.Trash-* | ||
|
||
# .nfs files are created when an open file is removed but is still being accessed | ||
.nfs* | ||
|
||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
# Windows thumbnail cache files | ||
Thumbs.db | ||
Thumbs.db:encryptable | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Dump file | ||
*.stackdump | ||
|
||
# Folder config file | ||
[Dd]esktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msix | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
target/ | ||
|
||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
|
||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
.mvn/wrapper/maven-wrapper.jar | ||
.flattened-pom.xml | ||
|
||
# Common working directory | ||
run/ |
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,92 @@ | ||
<?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>IgorLink</groupId> | ||
<artifactId>DonationExecutor</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>DonationExecutor</name> | ||
|
||
<description>Executes donations</description> | ||
<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> | ||
<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>mvnrepo-repo</id> | ||
<url>https://papermc.io/repo/repository/maven-public/</url> | ||
</repository> | ||
<repository> | ||
<id>sonatype</id> | ||
<url>https://oss.sonatype.org/content/groups/public/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.papermc.paper</groupId> | ||
<artifactId>paper-api</artifactId> | ||
<version>1.18.1-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.socket</groupId> | ||
<artifactId>engine.io-client</artifactId> | ||
<version>0.8.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.socket</groupId> | ||
<artifactId>socket.io-client</artifactId> | ||
<version>0.8.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.json</groupId> | ||
<artifactId>json</artifactId> | ||
<version>20190722</version> | ||
</dependency> | ||
</dependencies> | ||
</project> | ||
|
||
|
103 changes: 103 additions & 0 deletions
103
src/main/java/igorlink/DonationAlerts/DonationAlerts.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,103 @@ | ||
package igorlink.DonationAlerts; | ||
|
||
import igorlink.donationexecutor.DonationExecutor; | ||
import igorlink.donationexecutor.executionsstaff.Donation; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
import io.socket.emitter.Emitter.Listener; | ||
import io.socket.client.IO; | ||
import io.socket.client.Socket; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import static igorlink.service.Utils.logToConsole; | ||
|
||
|
||
public class DonationAlerts { | ||
private Listener connectListener; | ||
private Listener disconectListener; | ||
private Listener donationListener; | ||
private Listener errorListener; | ||
|
||
private URI url; | ||
private Socket socket; | ||
|
||
|
||
public DonationAlerts(String server) throws URISyntaxException { | ||
|
||
url = new URI(server); | ||
socket = IO.socket(url); | ||
|
||
connectListener = new Listener() { | ||
@Override | ||
public void call(Object... arg0) { | ||
logToConsole("Произведено успешное подключение!"); | ||
} | ||
}; | ||
|
||
disconectListener = new Listener() { | ||
@Override | ||
public void call(Object... arg0) { | ||
logToConsole("Соединение разорвано!"); | ||
} | ||
}; | ||
|
||
donationListener = new Listener() { | ||
@Override | ||
public void call(Object... arg0) { | ||
|
||
JSONObject json = new JSONObject((String) arg0[0]); | ||
json.toString(); | ||
new BukkitRunnable() { | ||
@Override | ||
public void run() { | ||
|
||
if ( (json.isNull("username")) || (json.isNull("amount_formatted"))) { | ||
return; | ||
} | ||
|
||
if ((json.getString("amount_formatted")).length() <= 1) { | ||
return; | ||
} | ||
|
||
DonationExecutor.getInstance().listOfStreamerPlayers | ||
.addToDonationsQueue(new Donation(Bukkit.getConsoleSender(), | ||
json.getString("username"), | ||
json.getString("amount_formatted"), | ||
json.getString("message"))); | ||
|
||
} | ||
}.runTask(Bukkit.getPluginManager().getPlugin("DonationExecutor")); | ||
|
||
} | ||
}; | ||
|
||
errorListener = new Listener() { | ||
@Override | ||
public void call(Object... arg0) { | ||
logToConsole("Произошла ошибка подключения к Donation Alerts!"); | ||
} | ||
}; | ||
|
||
socket.on(Socket.EVENT_CONNECT, connectListener) | ||
.on(Socket.EVENT_DISCONNECT, disconectListener) | ||
.on(Socket.EVENT_ERROR, errorListener) | ||
.on("donation", donationListener); | ||
} | ||
|
||
public void Connect (String token) throws JSONException { | ||
socket.connect(); | ||
socket.emit("add-user", new JSONObject() | ||
.put("token", token) | ||
.put("type", "minor")); | ||
} | ||
|
||
public void Disconnect() throws JSONException { | ||
socket.disconnect(); | ||
} | ||
|
||
public boolean getConnected() { | ||
return socket.connected(); | ||
} | ||
} |
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 igorlink.command; | ||
|
||
import igorlink.donationexecutor.DonationExecutor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.PluginCommand; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public abstract class AbstractCommand implements CommandExecutor { | ||
|
||
public AbstractCommand(String command) { | ||
PluginCommand pluginCommand = DonationExecutor.getInstance().getCommand(command); | ||
if (pluginCommand != null) { | ||
pluginCommand.setExecutor(this); | ||
} | ||
} | ||
|
||
public abstract Boolean execute(CommandSender sender, String label, String[] args); | ||
|
||
|
||
@Override | ||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { | ||
if (execute(sender, label, args)) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
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,43 @@ | ||
package igorlink.command; | ||
|
||
import igorlink.donationexecutor.DonationExecutor; | ||
import igorlink.donationexecutor.executionsstaff.Donation; | ||
import org.bukkit.command.CommandSender; | ||
|
||
public class DonateSubCommand { | ||
public static void onDonateCommand(CommandSender sender, String[] args) { | ||
int i; | ||
|
||
//Getting donation's amount | ||
String donationAmount = new String(); | ||
String donationUsername = new String(); | ||
String donationMessage = new String(); | ||
|
||
//Getting donation's amount | ||
donationAmount = args[0]; | ||
|
||
//Получаем имя донатера | ||
for (i = 1; i <= args.length - 1; i++) { | ||
if (args[i].equals("##")) { | ||
break; | ||
} | ||
else { | ||
if (i==1) { | ||
donationUsername = donationUsername + args[i]; | ||
} | ||
else { | ||
donationUsername = ' ' + donationUsername + args[i]; | ||
} | ||
} | ||
} | ||
|
||
//Все, что после символов ## - это сообщение | ||
for (i = i+1; i <= args.length - 1; i++) | ||
{ | ||
donationMessage = donationMessage + args[i] + ' '; | ||
} | ||
|
||
//Отправляем донат на исполнение | ||
DonationExecutor.getInstance().listOfStreamerPlayers.addToDonationsQueue(new Donation(sender, donationUsername, donationAmount+".00", donationMessage)); | ||
} | ||
} |
Oops, something went wrong.