Skip to content

Commit 8e59f9c

Browse files
committed
Initial Commit
0 parents  commit 8e59f9c

File tree

6 files changed

+289
-0
lines changed

6 files changed

+289
-0
lines changed

.gitignore

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# User-specific stuff
2+
.idea/
3+
4+
*.iml
5+
*.ipr
6+
*.iws
7+
8+
# IntelliJ
9+
out/
10+
11+
# Compiled class file
12+
*.class
13+
14+
# Log file
15+
*.log
16+
17+
# BlueJ files
18+
*.ctxt
19+
20+
# Package Files #
21+
*.jar
22+
*.war
23+
*.nar
24+
*.ear
25+
*.zip
26+
*.tar.gz
27+
*.rar
28+
29+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
30+
hs_err_pid*
31+
32+
*~
33+
34+
# temporary files which can be created if a process still has a handle open of a deleted file
35+
.fuse_hidden*
36+
37+
# KDE directory preferences
38+
.directory
39+
40+
# Linux trash folder which might appear on any partition or disk
41+
.Trash-*
42+
43+
# .nfs files are created when an open file is removed but is still being accessed
44+
.nfs*
45+
46+
# General
47+
.DS_Store
48+
.AppleDouble
49+
.LSOverride
50+
51+
# Icon must end with two \r
52+
Icon
53+
54+
# Thumbnails
55+
._*
56+
57+
# Files that might appear in the root of a volume
58+
.DocumentRevisions-V100
59+
.fseventsd
60+
.Spotlight-V100
61+
.TemporaryItems
62+
.Trashes
63+
.VolumeIcon.icns
64+
.com.apple.timemachine.donotpresent
65+
66+
# Directories potentially created on remote AFP share
67+
.AppleDB
68+
.AppleDesktop
69+
Network Trash Folder
70+
Temporary Items
71+
.apdisk
72+
73+
# Windows thumbnail cache files
74+
Thumbs.db
75+
Thumbs.db:encryptable
76+
ehthumbs.db
77+
ehthumbs_vista.db
78+
79+
# Dump file
80+
*.stackdump
81+
82+
# Folder config file
83+
[Dd]esktop.ini
84+
85+
# Recycle Bin used on file shares
86+
$RECYCLE.BIN/
87+
88+
# Windows Installer files
89+
*.cab
90+
*.msi
91+
*.msix
92+
*.msm
93+
*.msp
94+
95+
# Windows shortcuts
96+
*.lnk
97+
98+
target/
99+
100+
pom.xml.tag
101+
pom.xml.releaseBackup
102+
pom.xml.versionsBackup
103+
pom.xml.next
104+
105+
release.properties
106+
dependency-reduced-pom.xml
107+
buildNumber.properties
108+
.mvn/timing.properties
109+
.mvn/wrapper/maven-wrapper.jar
110+
.flattened-pom.xml
111+
112+
# Common working directory
113+
run/

pom.xml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>de</groupId>
8+
<artifactId>JavaExecutor</artifactId>
9+
<version>1.0.0</version>
10+
<packaging>jar</packaging>
11+
12+
<name>JavaExecutor</name>
13+
14+
<description>Execute your own Java code while ingame</description>
15+
<properties>
16+
<java.version>1.8</java.version>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
20+
<build>
21+
<plugins>
22+
<plugin>
23+
<groupId>org.apache.maven.plugins</groupId>
24+
<artifactId>maven-compiler-plugin</artifactId>
25+
<version>3.8.1</version>
26+
<configuration>
27+
<source>${java.version}</source>
28+
<target>${java.version}</target>
29+
</configuration>
30+
</plugin>
31+
<plugin>
32+
<groupId>org.apache.maven.plugins</groupId>
33+
<artifactId>maven-shade-plugin</artifactId>
34+
<version>3.2.4</version>
35+
<executions>
36+
<execution>
37+
<phase>package</phase>
38+
<goals>
39+
<goal>shade</goal>
40+
</goals>
41+
<configuration>
42+
<createDependencyReducedPom>false</createDependencyReducedPom>
43+
</configuration>
44+
</execution>
45+
</executions>
46+
</plugin>
47+
</plugins>
48+
<resources>
49+
<resource>
50+
<directory>src/main/resources</directory>
51+
<filtering>true</filtering>
52+
</resource>
53+
</resources>
54+
</build>
55+
56+
<repositories>
57+
<repository>
58+
<id>papermc-repo</id>
59+
<url>https://repo.papermc.io/repository/maven-public/</url>
60+
</repository>
61+
<repository>
62+
<id>sonatype</id>
63+
<url>https://oss.sonatype.org/content/groups/public/</url>
64+
</repository>
65+
</repositories>
66+
67+
<dependencies>
68+
<dependency>
69+
<groupId>org.apache-extras.beanshell</groupId>
70+
<artifactId>bsh</artifactId>
71+
<version>2.0b6</version>
72+
</dependency>
73+
<dependency>
74+
<groupId>io.papermc.paper</groupId>
75+
<artifactId>paper-api</artifactId>
76+
<version>1.19.2-R0.1-SNAPSHOT</version>
77+
<scope>provided</scope>
78+
</dependency>
79+
</dependencies>
80+
</project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package de.tamion;
2+
3+
import de.tamion.commands.Execute;
4+
import de.tamion.commands.ExecuteFile;
5+
import org.bukkit.plugin.java.JavaPlugin;
6+
7+
public final class JavaExecutor extends JavaPlugin {
8+
9+
@Override
10+
public void onEnable() {
11+
getCommand("execute").setExecutor(new Execute());
12+
getCommand("executefile").setExecutor(new ExecuteFile());
13+
}
14+
15+
@Override
16+
public void onDisable() {
17+
18+
}
19+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package de.tamion.commands;
2+
3+
import bsh.EvalError;
4+
import bsh.Interpreter;
5+
import org.bukkit.command.Command;
6+
import org.bukkit.command.CommandExecutor;
7+
import org.bukkit.command.CommandSender;
8+
import org.jetbrains.annotations.NotNull;
9+
10+
public class Execute implements CommandExecutor {
11+
12+
@Override
13+
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
14+
if(!sender.hasPermission("JavaExecutor.execute")) {
15+
sender.sendMessage("You aren't allowed to execute this Command");
16+
return false;
17+
}
18+
if(args.length == 0) {
19+
sender.sendMessage("Please provide code to execute");
20+
return false;
21+
}
22+
Interpreter inter = new Interpreter();
23+
try {
24+
inter.eval(String.join(" ", args));
25+
sender.sendMessage("Executed Code");
26+
} catch (EvalError e) {
27+
sender.sendMessage("Something went wrong");
28+
throw new RuntimeException(e);
29+
}
30+
return true;
31+
}
32+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package de.tamion.commands;
2+
3+
import bsh.Interpreter;
4+
import org.bukkit.Bukkit;
5+
import org.bukkit.command.Command;
6+
import org.bukkit.command.CommandExecutor;
7+
import org.bukkit.command.CommandSender;
8+
import org.jetbrains.annotations.NotNull;
9+
10+
import java.nio.file.Files;
11+
import java.nio.file.Paths;
12+
13+
public class ExecuteFile implements CommandExecutor {
14+
@Override
15+
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
16+
if(!sender.hasPermission("JavaExecutor.executefile")) {
17+
sender.sendMessage("You aren't allowed to execute this Command");
18+
return false;
19+
}
20+
if(args.length != 1) {
21+
sender.sendMessage("Please provide Path of File to execute");
22+
return false;
23+
}
24+
Interpreter inter = new Interpreter();
25+
try {
26+
inter.eval(new String(Files.readAllBytes(Paths.get(args[0]))));
27+
sender.sendMessage("Executed Code");
28+
Bukkit.getLogger().info("test");
29+
} catch (Exception e) {
30+
sender.sendMessage("Something went wrong");
31+
throw new RuntimeException(e);
32+
}
33+
return true;
34+
}
35+
}

src/main/resources/plugin.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: JavaExecutor
2+
version: '${project.version}'
3+
main: de.tamion.JavaExecutor
4+
api-version: 1.19
5+
authors: [Tamion]
6+
description: Execute your own Java code while ingame
7+
8+
commands:
9+
execute:
10+
executefile:

0 commit comments

Comments
 (0)