-
Notifications
You must be signed in to change notification settings - Fork 0
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
uweb
committed
Jul 10, 2023
0 parents
commit f02833b
Showing
24 changed files
with
772 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/ |
Empty file.
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,76 @@ | ||
<?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>de.uweb95</groupId> | ||
<artifactId>WorldCreator</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>WorldCreator</name> | ||
|
||
<description>A simple plugin to generate and import worlds</description> | ||
<properties> | ||
<java.version>1.8</java.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<url>https://mc.lunar-software.eu</url> | ||
|
||
<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>papermc-repo</id> | ||
<url>https://repo.papermc.io/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.20-R0.1-SNAPSHOT</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,17 @@ | ||
package de.uweb95.worldcreator; | ||
|
||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public final class WorldCreator extends JavaPlugin { | ||
|
||
@Override | ||
public void onEnable() { | ||
// Plugin startup logic | ||
|
||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
// Plugin shutdown logic | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/de/uweb95/worldcreator/commands/CommandInterface.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,17 @@ | ||
package de.uweb95.minebay.commands; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.List; | ||
|
||
public interface CommandInterface { | ||
boolean onlyPlayer = false; | ||
|
||
boolean checkPermissions(Player player); | ||
|
||
boolean executeCommand(CommandSender sender, Command command, String commandLabel, String[] args); | ||
|
||
List<String> onTabComplete(CommandSender sender, Command command, String commandLabel, String[] args); | ||
} |
75 changes: 75 additions & 0 deletions
75
src/main/java/de/uweb95/worldcreator/commands/CommandManager.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,75 @@ | ||
package de.uweb95.minebay.commands; | ||
|
||
import de.uweb95.minebay.util.Message; | ||
import de.uweb95.minebay.util.Translation; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.*; | ||
|
||
public class CommandManager implements CommandInterface { | ||
private final Map<String, CommandInterface> commands = new HashMap<>(); | ||
|
||
public void registerCommand(String command, CommandInterface commandClass) { | ||
commands.put(command, commandClass); | ||
} | ||
|
||
public void unregisterCommand(String command) { | ||
commands.remove(command); | ||
} | ||
|
||
@Override | ||
public boolean checkPermissions(Player player) { | ||
return player.hasPermission("minebay"); | ||
} | ||
|
||
@Override | ||
public boolean executeCommand(CommandSender sender, Command command, String commandLabel, String[] args) { | ||
CommandInterface selectedCommand = null; | ||
|
||
if (args.length > 0) { | ||
selectedCommand = commands.get(args[0]); | ||
} | ||
|
||
if (selectedCommand != null) { | ||
if (sender instanceof Player && !selectedCommand.checkPermissions((Player) sender)) { | ||
return false; | ||
} | ||
|
||
return selectedCommand.executeCommand(sender, command, commandLabel, args); | ||
} | ||
|
||
sendHelpMessage(sender); | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public List<String> onTabComplete(CommandSender sender, Command command, String commandLabel, String[] args) { | ||
List<String> options = new ArrayList<>(); | ||
|
||
if (args.length > 1) { | ||
CommandInterface selectedCommand; | ||
selectedCommand = commands.get(args[0]); | ||
|
||
if (selectedCommand == null) { | ||
return null; | ||
} | ||
|
||
return selectedCommand.onTabComplete(sender, command, commandLabel, args); | ||
} | ||
|
||
commands.forEach((key, value) -> options.add(key)); | ||
|
||
return options; | ||
} | ||
|
||
private void sendHelpMessage(CommandSender sender) { | ||
StringBuilder builder = new StringBuilder(Translation.getTranslation("help")).append("\n"); | ||
|
||
commands.forEach((key, value) -> builder.append(key).append("\n")); | ||
|
||
sender.sendMessage(Message.pluginMessage(builder.toString())); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/de/uweb95/worldcreator/commands/CreateWorldCommand.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,34 @@ | ||
package de.uweb95.minebay.commands; | ||
|
||
import de.uweb95.minebay.util.Message; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.World; | ||
import org.bukkit.WorldCreator; | ||
import org.bukkit.WorldType; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.List; | ||
|
||
public class CreateWorldCommand implements CommandInterface { | ||
@Override | ||
public boolean checkPermissions(Player player) { | ||
return player.hasPermission("minebay.user") || player.hasPermission("minebay.admin"); | ||
} | ||
|
||
@Override | ||
public boolean executeCommand(CommandSender sender, Command command, String commandLabel, String[] args) { | ||
|
||
WorldCreator worldCreator = new WorldCreator("world_test"); | ||
worldCreator.type(WorldType.NORMAL); | ||
worldCreator.createWorld(); | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public List<String> onTabComplete(CommandSender sender, Command command, String commandLabel, String[] args) { | ||
return null; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/de/uweb95/worldcreator/commands/DeleteWorldCommand.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,33 @@ | ||
package de.uweb95.worldcreator.commands; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.World; | ||
import org.bukkit.WorldCreator; | ||
import org.bukkit.WorldType; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.List; | ||
|
||
public class ImportWorldCommand implements CommandInterface { | ||
@Override | ||
public boolean checkPermissions(Player player) { | ||
return player.hasPermission("minebay.user") || player.hasPermission("minebay.admin"); | ||
} | ||
|
||
@Override | ||
public boolean executeCommand(CommandSender sender, Command command, String commandLabel, String[] args) { | ||
Bukkit.createWorld(WorldCreator.name("world_test")); | ||
|
||
Bukkit.unloadWorld("world_test", false); | ||
Bukkit.getWorldContainer(); | ||
Bukkit.getWorld("world name").getWorldFolder().delete(); | ||
return true; | ||
} | ||
|
||
@Override | ||
public List<String> onTabComplete(CommandSender sender, Command command, String commandLabel, String[] args) { | ||
return null; | ||
} | ||
} |
Oops, something went wrong.