Initial commit

This commit is contained in:
2025-05-13 18:35:25 +02:00
commit a5b9aa3d33
29 changed files with 1545 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
# Project exclude paths
/.gradle/
/build/
/build/classes/java/main/
/out/
+3
View File
@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml
+12
View File
@@ -0,0 +1,12 @@
<component name="ArtifactManager">
<artifact type="jar" name="PoketDimensions">
<output-path>$PROJECT_DIR$/out/artifacts/PoketDimensions</output-path>
<root id="archive" name="PoketDimensions.jar">
<element id="directory" name="META-INF">
<element id="file-copy" path="$PROJECT_DIR$/META-INF/MANIFEST.MF" />
</element>
<element id="file-copy" path="$PROJECT_DIR$/src/main/resources/plugin.yml" />
<element id="module-output" name="untitled.main" />
</root>
</artifact>
</component>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="21" />
</component>
</project>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/modules/untitled.main.iml" filepath="$PROJECT_DIR$/.idea/modules/untitled.main.iml" />
</modules>
</component>
</project>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>PAPER</platformType>
<platformType>ADVENTURE</platformType>
</autoDetectTypes>
<projectReimportVersion>1</projectReimportVersion>
</configuration>
</facet>
</component>
</module>
+2
View File
@@ -0,0 +1,2 @@
Manifest-Version: 1.0
+49
View File
@@ -0,0 +1,49 @@
plugins {
id 'java'
}
group = 'dev.siskel'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = "https://repo.papermc.io/repository/maven-public/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
}
def targetJavaVersion = 21
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release.set(targetJavaVersion)
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
View File
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+249
View File
@@ -0,0 +1,249 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+92
View File
@@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+1
View File
@@ -0,0 +1 @@
rootProject.name = 'untitled'
@@ -0,0 +1,61 @@
package dev.siskel.poketDimensions;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
import java.util.logging.Logger;
import dev.siskel.poketDimensions.commands.givepd;
import dev.siskel.poketDimensions.commands.pdgamerule;
import dev.siskel.poketDimensions.commands.pdtp;
import dev.siskel.poketDimensions.commands.player.pd;
import dev.siskel.poketDimensions.events.PlayerInteract;
import dev.siskel.poketDimensions.managers.InviteManager;
import dev.siskel.poketDimensions.managers.PoketDimensionManager;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
public final class PoketDimensions extends JavaPlugin {
public Logger logger = this.getLogger();
public PoketDimensions() {
}
@Override
public void onEnable() {
/*PluginManager var10002 = Bukkit.getPluginManager();
File f = new File(var10002.getPlugin("PocketDimensions").getDataFolder() + "/");
if (!f.exists()) {
f.mkdir();
}*/
getDataFolder().mkdirs();
File lastLocsFile = new File(getDataFolder(), "lastlocs.json");
try {
if (lastLocsFile.createNewFile()) {
this.logger.info("lastlocs.json file created successfully.");
}
} catch (IOException e) {
this.logger.severe("An error occurred while creating lastlocs.json: " + e.getMessage());
}
InviteManager inviteManager = new InviteManager();
PoketDimensionManager pocketDimensionManager = new PoketDimensionManager();
this.getServer().getPluginManager().registerEvents(new PlayerInteract(), this);
((PluginCommand)Objects.requireNonNull(this.getCommand("givepd"))).setExecutor(new givepd());
((PluginCommand)Objects.requireNonNull(this.getCommand("pdtp"))).setExecutor(new pdtp());
((PluginCommand)Objects.requireNonNull(this.getCommand("pd"))).setExecutor(new pd(inviteManager, pocketDimensionManager));
((PluginCommand)Objects.requireNonNull(this.getCommand("pdgamerule"))).setExecutor(new pdgamerule());
this.logger.info("Plugin Activated!");
}
@Override
public void onDisable() {
this.logger.info("Shutting Down!");
}
}
@@ -0,0 +1,21 @@
package dev.siskel.poketDimensions.classes;
import org.bukkit.entity.Player;
public class InviteRequest {
private final Player from;
private final Player to;
public InviteRequest(Player from, Player to) {
this.to = to;
this.from = from;
}
public Player getTo() {
return this.to;
}
public Player getFrom() {
return this.from;
}
}
@@ -0,0 +1,15 @@
package dev.siskel.poketDimensions.classes;
import org.bukkit.World;
import org.bukkit.generator.ChunkGenerator;
import java.util.Random;
public class VoidWorldGenerator {
public static class VoidWorld extends ChunkGenerator {
@Override
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
return createChunkData(world); // Return an empty chunk
}
}
}
@@ -0,0 +1,57 @@
package dev.siskel.poketDimensions.classes;
import dev.siskel.poketDimensions.managers.LocationManager;
import org.bukkit.*;
import org.bukkit.entity.Player;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
public class teleportToPD extends Thread {
private World playerpd;
private Player p;
private LocationManager locman;
public teleportToPD(World playerpd, Player p, LocationManager locman) {
this.playerpd = playerpd;
this.p = p;
this.locman = locman;
}
@Override
public void run() {
double currentHealth = p.getHealth();
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
for (int i = 3; i > 0; i--) {
p.sendTitle("Sending you to you PD", "In " + i + " second" + (i == 1 ? "" : "s"), 0, 40, 0);
if (p.getHealth() < currentHealth || p.isDead()) {
p.sendTitle("Teleport Cancelled", "", 0, 2, 0);
return;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Bukkit.getLogger().info("test");
}
p.sendTitle("", "", 0, 2, 0);
locman.saveLastLocation(p, false);
p.sendMessage(ChatColor.GREEN + "Sending you to your Pocket Dimension!");
Location lastPDLocation = locman.getLastLocation(p, true);
float yaw = (Float) locman.getLastLocationYaw(p, true);
float pitch = (Float) locman.getLastLocationPitch(p, true);
if (lastPDLocation != null) {
lastPDLocation.setYaw((float) yaw);
lastPDLocation.setPitch((float) pitch);
p.teleport(lastPDLocation);
} else {
p.teleport(playerpd.getSpawnLocation());
}
}
}
@@ -0,0 +1,57 @@
package dev.siskel.poketDimensions.commands;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
public class givepd implements CommandExecutor {
public givepd() {
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if ((sender instanceof Player) && sender.isOp()) {
sender.sendMessage("This command can only be executed by a player.");
return true;
} else {
/*Player player = (Player)sender;
if (sender instanceof Player) {
player = ((Player)sender).getPlayer();
}*/
if (args[0] == null) {
/*if (sender instanceof Player) {
player.sendMessage("Mention a player. Usage: /givepd <playername>");
}*/
return true;
} else {
ItemStack pdItem = new ItemStack(Material.ECHO_SHARD);
ItemMeta pdItemMeta = pdItem.getItemMeta();
NamespacedKey pdKey = new NamespacedKey("lgppd", "pocketdimension");
if (Bukkit.getOnlinePlayers().contains(args[0])) {
Player playerg = Bukkit.getPlayer(args[0]);
ChatColor var10001 = ChatColor.LIGHT_PURPLE;
pdItemMeta.setDisplayName(var10001 + playerg.getName() + "'s Pocket Dimension");
pdItemMeta.getPersistentDataContainer().set(pdKey, PersistentDataType.STRING, playerg.getUniqueId().toString());
} else {
OfflinePlayer playergo = Bukkit.getOfflinePlayer(args[0]);
ChatColor var11 = ChatColor.LIGHT_PURPLE;
pdItemMeta.setDisplayName(var11 + playergo.getName() + "'s Pocket Dimension");
pdItemMeta.getPersistentDataContainer().set(pdKey, PersistentDataType.STRING, playergo.getUniqueId().toString());
}
Player player = Bukkit.getPlayer(args[0]);
pdItem.setItemMeta(pdItemMeta);
player.getInventory().addItem(new ItemStack[]{pdItem});
return true;
}
}
}
}
@@ -0,0 +1,113 @@
package dev.siskel.poketDimensions.commands;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.GameRule;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
public class pdgamerule implements CommandExecutor, TabCompleter {
public pdgamerule() {
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command can only be executed by a player.");
return true;
} else {
Player player = (Player)sender;
if (args.length < 2) {
player.sendMessage("Usage: /pdgamerule <playername> <gamerule> [value]");
return true;
} else {
OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(args[0]);
String worldName = "pocketdimension-" + targetPlayer.getUniqueId().toString();
File worldFolder = new File(Bukkit.getWorldContainer(), worldName);
if (worldFolder.exists() && worldFolder.isDirectory()) {
World targetWorld = Bukkit.getWorld(worldName);
if (targetWorld == null) {
targetWorld = (new WorldCreator(worldName)).createWorld();
}
GameRule<?> gameRule = GameRule.getByName(args[1]);
if (gameRule == null) {
player.sendMessage("Unknown game rule: " + args[1]);
return true;
} else if (args.length == 2) {
Object currentValue = targetWorld.getGameRuleValue(gameRule);
if (currentValue != null) {
player.sendMessage("Current value of " + args[1] + ": " + currentValue.toString());
} else {
player.sendMessage("Unable to get the value for game rule " + args[1]);
}
return true;
} else {
String inputValue = args[2];
try {
if (gameRule.getType() == Boolean.class) {
if (!inputValue.equalsIgnoreCase("true") && !inputValue.equalsIgnoreCase("false")) {
player.sendMessage("Invalid Value, Valid Values are: true, false");
return true;
}
Boolean value = Boolean.parseBoolean(inputValue);
targetWorld.setGameRule((GameRule<Boolean>) gameRule, value);
} else {
if (gameRule.getType() != Integer.class) {
player.sendMessage("Unsupported game rule type.");
return true;
}
if (!inputValue.matches("[0-9]+")) {
player.sendMessage("Invalid Value, Valid Values are integers only.");
return true;
}
Integer value = Integer.parseInt(inputValue);
targetWorld.setGameRule((GameRule<Integer>) gameRule, value);
}
player.sendMessage("Game rule " + args[1] + " set to " + inputValue);
} catch (NumberFormatException var13) {
player.sendMessage("Invalid value for game rule " + args[1]);
}
return true;
}
} else {
player.sendMessage("That player doesn't have a pocket dimension.");
return true;
}
}
}
}
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
List<String> suggestions = new ArrayList();
if (args.length == 2) {
OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(args[0]);
String worldName = "pocketdimension-" + targetPlayer.getUniqueId().toString();
World targetWorld = Bukkit.getWorld(worldName);
if (targetWorld != null) {
for(String gameRule : targetWorld.getGameRules()) {
if (gameRule.toLowerCase().startsWith(args[1].toLowerCase())) {
suggestions.add(gameRule);
}
}
}
}
return suggestions;
}
}
@@ -0,0 +1,47 @@
package dev.siskel.poketDimensions.commands;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class pdtp implements CommandExecutor {
public pdtp() {
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command can only be executed by a player.");
return true;
} else {
Player player = ((Player)sender).getPlayer();
if (args.length == 0) {
player.sendMessage("Mention a player. Usage: /pdtp <playername>");
return true;
} else {
OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(args[0]);
String worldName = "pocketdimension-" + targetPlayer.getUniqueId().toString();
File worldFolder = new File(Bukkit.getWorldContainer(), worldName);
if (worldFolder.exists() && worldFolder.isDirectory()) {
World targetWorld = Bukkit.getWorld(worldName);
if (targetWorld == null) {
targetWorld = (new WorldCreator(worldName)).createWorld();
}
player.sendMessage("Teleporting to " + targetPlayer.getName() + "'s pocket dimension.");
player.teleport(targetWorld.getSpawnLocation());
} else {
player.sendMessage("That player doesn't have a pocket dimension.");
}
return true;
}
}
}
}
@@ -0,0 +1,103 @@
package dev.siskel.poketDimensions.commands.player;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import dev.siskel.poketDimensions.managers.InviteManager;
import dev.siskel.poketDimensions.managers.PoketDimensionManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
public class pd implements CommandExecutor, TabCompleter{
public static final String[] actionlist = new String[]{"invite", "kick", "acceptinv"};
public Logger logger = Bukkit.getLogger();
private final Plugin plugin = Bukkit.getPluginManager().getPlugin("PoketDimensions");
private final InviteManager inviteManager;
private final PoketDimensionManager pocketDimensionManager;
public pd(InviteManager inviteManager, PoketDimensionManager pocketDimensionManager) {
this.inviteManager = inviteManager;
this.pocketDimensionManager = pocketDimensionManager;
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command can only be executed by a player.");
return true;
} else {
Player player = ((Player)sender).getPlayer();
if (args.length != 0 && !args[0].isEmpty()) {
boolean isValidAction = Arrays.stream(actionlist).anyMatch((action) -> action.equals(args[0]));
if (!isValidAction) {
player.sendMessage("Invalid action. Valid actions are: " + Arrays.toString(actionlist));
return true;
} else {
this.logger.info(Arrays.toString(args));
if (args[0].equals("invite")) {
if (!player.hasPermission("pocketdimensions.commands.player.pd.invite")) {
player.sendMessage(ChatColor.RED + "No permission");
return true;
} else if (args.length < 2) {
player.sendMessage("You must specify a player for this action.\nUsage:/pd invite <player>");
return true;
} else {
String targetPlayerName = args[1];
Player targetPlayer = Bukkit.getPlayer(targetPlayerName);
if (targetPlayer == null) {
player.sendMessage("The specified player is not online.");
return true;
} else {
this.inviteManager.sendInvite(player, targetPlayer);
return true;
}
}
} else {
if (args[0].equals("acceptinv")) {
this.inviteManager.acceptInvite((Player)Objects.requireNonNull(((Player)sender).getPlayer()));
}
if (args[0].equals("kick")) {
if (!player.hasPermission("pocketdimensions.commands.player.pd.kick")) {
player.sendMessage(ChatColor.RED + "No permission");
return true;
}
if (args.length < 2) {
player.sendMessage("You must specify a player for this action.\nUsage:/pd kick <player>");
return true;
}
String targetPlayerName = args[1];
Player targetPlayer = Bukkit.getPlayer(targetPlayerName);
this.pocketDimensionManager.kick(player, targetPlayer);
}
return true;
}
}
} else {
player.sendMessage("Mention an action. Usage: /pd <action> [player]");
return true;
}
}
}
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
if (args.length == 1) {
return Arrays.asList(actionlist);
} else {
return args.length == 2 ? (List)Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList()) : null;
}
}
}
@@ -0,0 +1,223 @@
package dev.siskel.poketDimensions.events;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.logging.Logger;
import dev.siskel.poketDimensions.classes.VoidWorldGenerator;
import dev.siskel.poketDimensions.classes.teleportToPD;
import dev.siskel.poketDimensions.managers.LocationManager;
import org.bukkit.*;
import org.bukkit.World.Environment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.Plugin;
public class PlayerInteract implements Listener {
public Logger logger = Bukkit.getLogger();
private final Plugin plugin = Bukkit.getPluginManager().getPlugin("PoketDimensions");
private final Map<UUID, Long> cooldowns = new HashMap();
private static final long COOLDOWN_TIME = 1000L;
private static final int WORLD_BORDER_SIZE = 10000;
public PlayerInteract() {
}
private void createBasePlatform(World world) {
Location spawnLocation = world.getSpawnLocation();
int platformSize = 20; // Size of the platform (5x5)
for (int x = -platformSize / 2; x <= platformSize / 2; x++) {
for (int z = -platformSize / 2; z <= platformSize / 2; z++) {
Location blockLocation = spawnLocation.clone().add(x, -1, z);
blockLocation.getBlock().setType(Material.STONE); // Set the block type for the platform
}
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
final Player p = event.getPlayer();
UUID playerUUID = p.getUniqueId();
if (this.cooldowns.containsKey(playerUUID)) {
long lastInteractTime = (Long)this.cooldowns.get(playerUUID);
if (System.currentTimeMillis() - lastInteractTime < 1000L) {
return;
}
}
this.cooldowns.put(playerUUID, System.currentTimeMillis());
Action a = event.getAction();
NamespacedKey pdKey = new NamespacedKey("lgppd", "pocketdimension");
final LocationManager locman = new LocationManager();
ItemStack item = event.getItem();
if (item != null && item.getType() != Material.AIR) {
if (event.getHand() == EquipmentSlot.HAND) {
ItemMeta meta = item.getItemMeta();
if (meta != null && meta.getPersistentDataContainer().has(pdKey, PersistentDataType.STRING)) {
String pdValue = (String) meta.getPersistentDataContainer().get(pdKey, PersistentDataType.STRING);
World playerpdd = Bukkit.getWorld("pocketdimension-" + p.getUniqueId().toString());
if ((a == Action.RIGHT_CLICK_BLOCK || a == Action.RIGHT_CLICK_AIR) && pdValue != null && pdValue.equals(p.getUniqueId().toString()) && playerpdd == null) {
WorldCreator pocketdimensioncreator = (new WorldCreator("pocketdimension-" + p.getUniqueId().toString())).type(WorldType.FLAT).generateStructures(false).seed(1L).environment(Environment.NORMAL).generator(new VoidWorldGenerator.VoidWorld());
p.sendMessage(ChatColor.GREEN + "Loading your pocket dimension!");
playerpdd = Bukkit.createWorld(pocketdimensioncreator);
if (playerpdd == null) {
p.sendMessage(ChatColor.RED + "Failed to create the pocket dimension.");
this.logger.severe("Failed to create the pocket dimension.");
return;
}
playerpdd.setSpawnLocation(0, -60, 0);
createBasePlatform(playerpdd);
}
if (p.getWorld() != Bukkit.getWorld("pocketdimension-" + p.getUniqueId().toString())) {
final World playerpd = Bukkit.getWorld("pocketdimension-" + p.getUniqueId().toString());
if (playerpd != null) {
WorldBorder worldBorder = playerpd.getWorldBorder();
worldBorder.setCenter((double) 0.0F, (double) 0.0F);
worldBorder.setSize((double) 480.0F);
playerpd.setGameRule(GameRule.DO_MOB_SPAWNING, false);
playerpd.setGameRule(GameRule.DO_IMMEDIATE_RESPAWN, true);
playerpd.setGameRule(GameRule.DO_PATROL_SPAWNING, false);
playerpd.setGameRule(GameRule.DO_TRADER_SPAWNING, false);
playerpd.setGameRule(GameRule.DROWNING_DAMAGE, false);
playerpd.setGameRule(GameRule.FALL_DAMAGE, false);
playerpd.setGameRule(GameRule.DO_WARDEN_SPAWNING, false);
playerpd.setGameRule(GameRule.KEEP_INVENTORY, true);
playerpd.setGameRule(GameRule.MOB_GRIEFING, true);
playerpd.setGameRule(GameRule.MAX_ENTITY_CRAMMING, 500);
playerpd.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
//teleportToPD thread = new teleportToPD(playerpd, p, locman);
//thread.start();
double currentHealth = p.getHealth();
double currentPosX = p.getLocation().getX();
double currentPosY = p.getLocation().getY();
double currentPosZ = p.getLocation().getZ();
for (int i = 3; i > 0; i--) {
int countdown = i;
Bukkit.getScheduler().runTaskLater(plugin, () -> {
if (p.getHealth() < currentHealth
|| (
p.getLocation().getX() != currentPosX
&& (p.getLocation().getX() > (currentPosX + 1) || p.getLocation().getX() < (currentPosX - 1))
)
|| (
p.getLocation().getY() != currentPosY
&& (p.getLocation().getY() > (currentPosY + 1) || p.getLocation().getY() < (currentPosY - 1))
)
|| (
p.getLocation().getZ() != currentPosZ
&& ( p.getLocation().getZ() > (currentPosZ + 1) || p.getLocation().getZ() < (currentPosZ - 1))
)
) {
p.sendTitle(ChatColor.RED + "Teleport Cancelled", "", 0, 40, 0);
return;
}
p.sendTitle(ChatColor.GREEN + "Sending you to your PD", ChatColor.GREEN + "In " + countdown + " second" + (countdown == 1 ? "" : "s"), 0, 40, 0);
}, (3 - i) * 20L); // Schedule each iteration 1 second apart (20 ticks = 1 second)
}
// Schedule the teleportation logic after the countdown
Bukkit.getScheduler().runTaskLater(plugin, () -> {
if (p.getHealth() < currentHealth || p.isDead()
|| (
p.getLocation().getX() != currentPosX
&& (p.getLocation().getX() > (currentPosX + 1) || p.getLocation().getX() < (currentPosX - 1))
)
|| (
p.getLocation().getY() != currentPosY
&& (p.getLocation().getY() > (currentPosY + 1) || p.getLocation().getY() < (currentPosY - 1))
)
|| (
p.getLocation().getZ() != currentPosZ
&& ( p.getLocation().getZ() > (currentPosZ + 1) || p.getLocation().getZ() < (currentPosZ - 1))
)
) {
p.sendTitle(ChatColor.RED + "Teleport Cancelled", "", 0, 2, 0);
return;
}
p.sendTitle("", "", 0, 2, 0);
locman.saveLastLocation(p, false);
p.sendMessage(ChatColor.GREEN + "Sending you to your Pocket Dimension!");
Location lastPDLocation = locman.getLastLocation(p, true);
float yaw = (Float) locman.getLastLocationYaw(p, true);
float pitch = (Float) locman.getLastLocationPitch(p, true);
if (lastPDLocation != null) {
lastPDLocation.setYaw(yaw);
lastPDLocation.setPitch(pitch);
p.teleport(lastPDLocation); // This is now executed synchronously
} else {
p.teleport(playerpd.getSpawnLocation()); // This is also executed synchronously
}
}, 60L); // Schedule teleportation after 3 seconds (60 ticks)
} else {
p.sendMessage(ChatColor.RED + "Failed to load the pocket dimension.");
this.logger.severe("Failed to load the pocket dimension.");
}
} else if (p.getWorld() == Bukkit.getWorld("pocketdimension-" + p.getUniqueId().toString()) && Bukkit.getWorld("pocketdimension-" + p.getUniqueId().toString()) != null) {
p.sendMessage("Sending you back to the main world.");
locman.saveLastLocation(p, true);
Location lastLocation = locman.getLastLocation(p, false);
float yaw = (Float) locman.getLastLocationYaw(p, false);
float pitch = (Float) locman.getLastLocationPitch(p, false);
if (lastLocation != null) {
lastLocation.setYaw((float) yaw);
lastLocation.setPitch((float) pitch);
p.teleport(lastLocation);
} else {
p.teleport(Bukkit.getWorld("world").getSpawnLocation());
}
}
}
}
}
}
public static void SendingDelay(int milliseconds) {
//System.out.println("Task started");
CompletableFuture.runAsync(() -> {
try {
// Simulate a delay
Thread.sleep(milliseconds);
} catch (InterruptedException e) {
e.printStackTrace();
}
//System.out.println("Task completed after 2 seconds");
});
// Continue with other tasks
//System.out.println("Continuing with other tasks...");
}
}
@@ -0,0 +1,76 @@
package dev.siskel.poketDimensions.managers;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Logger;
import dev.siskel.poketDimensions.classes.InviteRequest;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
public class InviteManager {
public Logger logger = Bukkit.getLogger();
private final Plugin plugin = Bukkit.getPluginManager().getPlugin("PoketDimensions");
private final Map<UUID, InviteRequest> invites = new HashMap();
LocationManager locman = new LocationManager();
public InviteManager() {
}
public void sendInvite(final Player playerFrom, final Player playerTo) {
if (Bukkit.getWorld("pocketdimension-" + playerFrom.getUniqueId().toString()) == null) {
playerFrom.sendMessage("You don't have a pocket dimension!");
} else {
World pocketDimensionWorld = Bukkit.getWorld("pocketdimension-" + playerFrom.getUniqueId().toString());
if (playerFrom.getWorld() != pocketDimensionWorld) {
playerFrom.sendMessage("You're not in your pocket dimension!");
} else {
if (playerFrom.getUniqueId() == playerTo.getUniqueId()) {
playerFrom.sendMessage(ChatColor.RED + "You can't send invites to yourself!");
}
this.invites.put(playerTo.getUniqueId(), new InviteRequest(playerFrom, playerTo));
ChatColor var10001 = ChatColor.GREEN;
playerFrom.sendMessage(var10001 + "Invited " + playerTo.getName() + " Successfully!");
playerTo.sendMessage("You have been invited to " + playerFrom.getName() + "'s Pocket Dimension!\nUse: /pd acceptinv \n To accept it. This expires in 120 seconds(2 Minutes).");
(new BukkitRunnable() {
public void run() {
if (InviteManager.this.invites.remove(playerTo.getUniqueId()) != null) {
ChatColor var10001 = ChatColor.RED;
playerFrom.sendMessage(var10001 + "Invite to " + playerTo.getName() + " has expired.");
var10001 = ChatColor.RED;
playerTo.sendMessage(var10001 + "Your invite from " + playerFrom.getName() + " has expired.");
}
}
}).runTaskLater(this.plugin, 2400L);
}
}
}
public void acceptInvite(Player playerTo) {
InviteRequest invite = (InviteRequest)this.invites.get(playerTo.getUniqueId());
this.logger.info("Invites: " + this.invites.toString());
if (invite == null) {
playerTo.sendMessage(ChatColor.RED + "No invites.");
} else {
String worldName = "pocketdimension-" + invite.getFrom().getUniqueId().toString();
World pocketDimensionWorld = Bukkit.getWorld(worldName);
if (pocketDimensionWorld == null) {
playerTo.sendMessage("Hmm, we can't find that pocket dimension. Ask for another invite?");
this.logger.warning("World not found: " + worldName);
} else {
playerTo.sendMessage("Going to " + invite.getFrom().getName() + "'s Pocket Dimension!");
this.locman.saveLastLocation(playerTo, false);
playerTo.teleport(pocketDimensionWorld.getSpawnLocation());
this.invites.remove(playerTo.getUniqueId());
}
}
}
}
@@ -0,0 +1,225 @@
package dev.siskel.poketDimensions.managers;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
public class LocationManager {
public Logger logger = Bukkit.getLogger();
private final Plugin plugin = Bukkit.getPluginManager().getPlugin("PoketDimensions");
public LocationManager() {
}
public void saveLastLocation(Player player, boolean isPocketDimension) {
File file = new File(this.plugin.getDataFolder(), "lastlocs.json");
JSONObject locations = new JSONObject();
if (file.exists()) {
try {
FileReader reader = new FileReader(file);
try {
JSONParser parser = new JSONParser();
locations = (JSONObject)parser.parse(reader);
} catch (Throwable var13) {
try {
reader.close();
} catch (Throwable var12) {
var13.addSuppressed(var12);
}
throw var13;
}
reader.close();
} catch (ParseException | IOException e) {
this.logger.severe("An error occurred while reading lastlocs.json: " + ((Exception)e).getMessage());
}
}
JSONObject location = new JSONObject();
location.put("world", player.getWorld().getName());
location.put("x", player.getLocation().getX());
location.put("y", player.getLocation().getY());
location.put("z", player.getLocation().getZ());
location.put("h", player.getLocation().getYaw());
location.put("v", player.getLocation().getPitch());
if (isPocketDimension) {
locations.put(player.getUniqueId().toString() + "_pd", location);
} else {
if (!player.getLocation().getWorld().toString().contains("pocketdimension")) {
locations.put(player.getUniqueId().toString(), location);
}
}
try {
FileWriter writer = new FileWriter(file);
try {
writer.write(locations.toJSONString());
} catch (Throwable var10) {
try {
writer.close();
} catch (Throwable var9) {
var10.addSuppressed(var9);
}
throw var10;
}
writer.close();
} catch (IOException e) {
this.logger.severe("An error occurred while writing to lastlocs.json: " + e.getMessage());
}
}
public Location getLastLocation(Player player, boolean isPocketDimension) {
File file = new File(this.plugin.getDataFolder(), "lastlocs.json");
if (!file.exists()) {
return null;
} else {
try {
FileReader reader = new FileReader(file);
label38: {
Location var16;
try {
JSONParser parser = new JSONParser();
JSONObject locations = (JSONObject)parser.parse(reader);
String var10000 = player.getUniqueId().toString();
String key = var10000 + (isPocketDimension ? "_pd" : "");
JSONObject location = (JSONObject)locations.get(key);
if (location == null) {
break label38;
}
World world = Bukkit.getWorld((String)location.get("world"));
double x = (Double)location.get("x");
double y = (Double)location.get("y");
double z = (Double)location.get("z");
var16 = new Location(world, x, y, z);
} catch (Throwable var18) {
try {
reader.close();
} catch (Throwable var17) {
var18.addSuppressed(var17);
}
throw var18;
}
reader.close();
return var16;
}
reader.close();
} catch (ParseException | IOException e) {
this.logger.severe("An error occurred while reading lastlocs.json: " + ((Exception)e).getMessage());
}
return null;
}
}
public float getLastLocationPitch(Player player, boolean isPocketDimension) {
File file = new File(this.plugin.getDataFolder(), "lastlocs.json");
if (!file.exists()) {
return 0;
} else {
try {
FileReader reader = new FileReader(file);
label38: {
float v = 0;
try {
JSONParser parser = new JSONParser();
JSONObject locations = (JSONObject)parser.parse(reader);
String var10000 = player.getUniqueId().toString();
String key = var10000 + (isPocketDimension ? "_pd" : "");
JSONObject location = (JSONObject)locations.get(key);
if (location == null) {
break label38;
}
Double vdouble = (double) location.get("v");
v = vdouble.floatValue();
} catch (Throwable var18) {
try {
reader.close();
} catch (Throwable var17) {
var18.addSuppressed(var17);
}
throw var18;
}
reader.close();
return v;
}
reader.close();
} catch (ParseException | IOException e) {
this.logger.severe("An error occurred while reading lastlocs.json: " + ((Exception)e).getMessage());
}
return 0;
}
}
public float getLastLocationYaw(Player player, boolean isPocketDimension) {
File file = new File(this.plugin.getDataFolder(), "lastlocs.json");
if (!file.exists()) {
return 0;
} else {
try {
FileReader reader = new FileReader(file);
label38: {
float h = 0;
try {
JSONParser parser = new JSONParser();
JSONObject locations = (JSONObject)parser.parse(reader);
String var10000 = player.getUniqueId().toString();
String key = var10000 + (isPocketDimension ? "_pd" : "");
JSONObject location = (JSONObject)locations.get(key);
if (location == null) {
break label38;
}
Double hdouble = (double) location.get("h");
h = hdouble.floatValue();
} catch (Throwable var18) {
try {
reader.close();
} catch (Throwable var17) {
var18.addSuppressed(var17);
}
throw var18;
}
reader.close();
return h;
}
reader.close();
} catch (ParseException | IOException e) {
this.logger.severe("An error occurred while reading lastlocs.json: " + ((Exception)e).getMessage());
}
return 0;
}
}
}
@@ -0,0 +1,50 @@
package dev.siskel.poketDimensions.managers;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Logger;
import dev.siskel.poketDimensions.classes.InviteRequest;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class PoketDimensionManager {
private static final int WORLD_BORDER_SIZE = 10000;
public Logger logger = Bukkit.getLogger();
private final Plugin plugin = Bukkit.getPluginManager().getPlugin("PocketDimensions");
private final Map<UUID, InviteRequest> invites = new HashMap();
LocationManager locman = new LocationManager();
public PoketDimensionManager() {
}
public void kick(Player playerFrom, Player playerTo) {
if (Bukkit.getWorld("pocketdimension-" + playerFrom.getUniqueId().toString()) == null) {
playerFrom.sendMessage("ChatColor.RED + You don't have a pocket dimension!");
} else {
World pocketDimensionWorld = Bukkit.getWorld("pocketdimension-" + playerFrom.getUniqueId().toString());
if (playerFrom.getWorld() != playerTo.getWorld()) {
playerFrom.sendMessage(ChatColor.RED + "Player is not in your pocket dimension.");
} else if (!playerTo.hasPermission("pocketdimensions.commands.player.pd.kick.bypass") && !playerTo.isOp()) {
Location lastLocation = this.locman.getLastLocation(playerTo, false);
if (lastLocation != null) {
playerTo.teleport(lastLocation);
} else if (playerTo.getBedSpawnLocation() != null) {
playerTo.teleport(playerTo.getBedSpawnLocation());
} else {
playerTo.teleport(Bukkit.getWorld("world").getSpawnLocation());
}
playerFrom.sendMessage(ChatColor.GREEN + "Kicked Successfully!");
} else {
playerFrom.sendMessage(ChatColor.RED + "Unable to kick this player!");
}
}
}
}
+26
View File
@@ -0,0 +1,26 @@
name: PoketDimensions
version: '0.0.1'
main: dev.siskel.poketDimensions.PoketDimensions
api-version: '1.21'
load: STARTUP
commands:
givepd:
description: "Gives you an item for any players own pocketdimension!"
permission-message: "No Permissions"
permission: poketdimensions.commands.givepd
usage: "/givepd <player>"
pdtp:
description: "Lets an admin teleport into another players pocket dimension"
permission-message: "No Permissions"
permission: poketdimensions.commands.pdtp
usage: "/pdtp <player>"
pd:
description: "General Command for Pocket Dimensions"
permission-message: "No Permissions"
permission: poketdimensions.commands.players.pd
usage: "/pd <action> [player]"
pdgamerule:
description: "Set Gamerules in Pocket Dimensions"
permission-message: "No Permissions"
permission: poketdimensions.commands.pdgamerule
usage: "/pdgamerule <playername> <gamerule> [value]"