Skip to content

Commit

Permalink
Merge pull request #13 from ocelotpotpie/1.17
Browse files Browse the repository at this point in the history
1.17
  • Loading branch information
LadyCailin authored Jan 8, 2024
2 parents a767bee + 0ead8db commit ee28ac4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 52 deletions.
8 changes: 3 additions & 5 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: TPControl
version: ${project.version}
description: ${project.description}
description: Simple, configurable, tiered teleport plugin with allow/ask/deny modes.
website: ${project.url}
author: [Barney Gale, Deaygo, c45y, slide, Challenger2]
main: nu.nerd.tpcontrol.TPControl
softdepend: [Vault, WorldBorder, WorldGuard, Multiverse-Core]
api-version: 1.13
softdepend: [Vault, WorldGuard, Multiverse-Core]
api-version: 1.17

permissions:
tpcontrol.level.*:
Expand Down Expand Up @@ -33,8 +33,6 @@ permissions:
children:
tpcontrol.home: true

description:
Simple, configurable, tiered teleport plugin with allow/ask/deny modes.
commands:
tpcontrol:
description: TPControl admin functions
Expand Down
28 changes: 12 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>com.wimbli.WorldBorder</groupId>
<artifactId>WorldBorder</artifactId>
<version>1.9.10 (beta)</version>
<version>1.7</version>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
Expand All @@ -42,11 +38,11 @@
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
<url>https://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>sk89q</id>
<url>http://maven.sk89q.com/repo</url>
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
<repository>
<id>papermc</id>
Expand All @@ -73,7 +69,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<version>3.2.0</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
Expand All @@ -84,10 +80,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
</plugins>
Expand Down
44 changes: 13 additions & 31 deletions src/nu/nerd/tpcontrol/TPControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.command.Command;
Expand Down Expand Up @@ -47,8 +43,6 @@
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.wimbli.WorldBorder.BorderData;
import com.wimbli.WorldBorder.WorldBorder;

import net.milkbowl.vault.economy.Economy;

Expand All @@ -64,7 +58,6 @@ public class TPControl extends JavaPlugin implements Listener {
private UUIDCache uuidcache = null;

public Economy economy = null;
private WorldBorder worldBorder = null;
private WorldGuardPlugin worldGuard = null;

@Override
Expand All @@ -80,11 +73,7 @@ public void onEnable() {
}
}

Plugin plugin = getServer().getPluginManager().getPlugin("WorldBorder");
if (plugin != null && plugin instanceof WorldBorder)
worldBorder = (WorldBorder) plugin;

plugin = getServer().getPluginManager().getPlugin("WorldGuard");
Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
if (plugin != null && plugin instanceof WorldGuardPlugin)
worldGuard = (WorldGuardPlugin) plugin;

Expand Down Expand Up @@ -162,7 +151,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getClickedBlock() == null || event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
if (event.getClickedBlock().getType() == Material.WALL_SIGN) {
if (Tag.WALL_SIGNS.isTagged(event.getClickedBlock().getType())) {
Sign s = (Sign) event.getClickedBlock().getState();
Player p = event.getPlayer();
if (event.getItem() != null && event.getItem().getType() == Material.DIAMOND_HOE) {
Expand All @@ -181,7 +170,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
if (!s.getLine(1).isEmpty() && s.getLine(1).matches("\\s*-*\\d+\\s*,\\s*-*\\d+\\s*,\\s*-*\\d+\\s*")) {
String[] sCo = s.getLine(1).split(",");
// Change our strings to ints, remember to remove spaces
// because people can be stupid about fomatting
// because people can be stupid about formatting
Location tp = new Location(p.getWorld(), Integer.parseInt(sCo[0].trim()), Integer.parseInt(sCo[1].trim()),
Integer.parseInt(sCo[2].trim()));
p.teleport(tp);
Expand Down Expand Up @@ -1045,7 +1034,7 @@ private void cmdCancelWarp(CommandSender sender) {
*/
private void cmdRandLoc(CommandSender sender, String[] args) {
// Check perms
if (!(sender instanceof Player)) {
if (!(sender instanceof final Player p)) {
sender.sendMessage("Etherial beings cannot be teleported. Sorry :(");
return;
}
Expand All @@ -1056,32 +1045,25 @@ private void cmdRandLoc(CommandSender sender, String[] args) {
}

// Figure out the world size and setup
Player p = (Player) sender;
final World world = p.getWorld();
RegionManager regionManager = null;
BorderData borderData = null;
WorldBorder borderData = null;

if (worldGuard != null) {
com.sk89q.worldedit.world.World world = BukkitAdapter.adapt(p.getWorld());
regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(world);
}
if (worldBorder != null) {
borderData = worldBorder.getWorldBorder(p.getWorld().getName());
regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world));
}

// Figure out the world shape
if (borderData == null) {
p.sendMessage(ChatColor.RED + "ERROR: Cannot get world size from WorldBorder plugin");
return;
}
borderData = world.getWorldBorder();
final Location center = borderData.getCenter();

// Pick random locations until we find a good one
for (int i = 0; i < 100; i++) {
double x = (2.0 * Math.random() - 1.0) * borderData.getRadiusX() + borderData.getX();
double z = (2.0 * Math.random() - 1.0) * borderData.getRadiusZ() + borderData.getZ();
double x = (2.0 * Math.random() - 1.0) * borderData.getSize() + center.getX();
double z = (2.0 * Math.random() - 1.0) * borderData.getSize() + center.getZ();

// Reject all points outside the border. We need this because
// circular borders are smaller than our random location.
if (!borderData.insideBorder(x, z))
if (!borderData.isInside(new Location(world, x, world.getMinHeight(), z)))
continue;

// Calculate y offset
Expand Down

0 comments on commit ee28ac4

Please sign in to comment.