Sueta

Fredashay's Teleport Trespass Protect

2023-11-11

This plugin prevents players from using enderpearls (or other modes of teleportation) to trespass.

·Plugin
  1. 2023-11-11latestUpdated for 1.20Nov 11, 2023
    Updated for Minecraft 1.20.
    1 download
  2. 3.0Recompiled for 1.16Dec 19, 2020
    Recompiled for 1.16
    37 downloads
  3. 2017-09-30general improvementsSep 30, 2017
    This plugin prevents players from using enderpearls (or other modes of teleportation) to trespass into other players' houses through iron doors, glass panes, fences, etc. This will, hopefully, prevent theives from breaking into players' houses with enderpearls. The plugin will create a .properties for the plugin if one doesn't exist. The properties file will contain one line: "message=No trespassing!" You can change this message or remove it if you don't want your players to get a message if their teleport has been aborted. To install this plugin, copy the plugin JAR file to your server's plugins folder. Code (Text): package FredashaySpigotTeleportTrespassProtect; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import java.util.logging.Logger; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.command.CommandExecutor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; public class MyPlugin extends JavaPlugin implements Listener, CommandExecutor { private static Logger logger = null; private static PluginDescriptionFile pdfFile = null; private static Properties props = new Properties(); private static Player latestPlayer = null; private static String message = "No trespassing!"; @Override public void onEnable() { logger = Logger.getLogger("Minecraft"); pdfFile = getDescription(); String propertiesFileName = pdfFile.getName() + ".properties"; getProperties(propertiesFileName); getServer().getPluginManager().registerEvents(this,this); } private void getProperties(String fileName) { InputStream input = null; try { input = new FileInputStream(fileName); props.load(input); } catch (FileNotFoundException ok) { saveProperties(fileName); } catch (IOException oops) { logger.info("[" + pdfFile.getName() + "] Error reading properties file '" + fileName + "'. "); oops.printStackTrace(System.err); } finally { if (input != null) { try { input.close(); } catch (IOException oops) { oops.printStackTrace(System.err); } } } if (props.getProperty("MESSAGE") != null) { message = props.getProperty("MESSAGE"); } } private void saveProperties(String fileName) { OutputStream output = null; try { output = new FileOutputStream(fileName); props.setProperty("MESSAGE", message); props.store(output, null); } catch (IOException oops) { logger.info("[" + pdfFile.getName() + "] Error writing properties file '" + fileName + "'. "); oops.printStackTrace(System.err); } finally { try { output.close(); } catch (IOException oops) { oops.printStackTrace(System.err); } } } @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { latestPlayer = event.getPlayer(); } @EventHandler public void onTeleport(PlayerTeleportEvent event) { if (event.isCancelled() == false) { int subX = 0; int subY = 0; int subZ = 0; boolean nyet = false; Location here = null; Material thingy = null; Player player = null; if (event.getPlayer() instanceof Player) { player = event.getPlayer(); Location location = event.getTo(); World world = getServer().getWorld(location.getWorld().getUID()); subX = location.getBlockX() - 2; while ((subX <= location.getBlockX() + 2) && (nyet == false)) { subY = location.getBlockY() - 2; while ((subY <= location.getBlockY() + 2) && (nyet == false)) { subZ = location.getBlockZ() - 2; while ((subZ <= location.getBlockZ() + 2) && (nyet == false)) { if (world.getBlockAt(subX, subY, subZ).getType() == Material.ACACIA_FENCE) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.BIRCH_FENCE) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.COBBLE_WALL) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.DARK_OAK_FENCE) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.FENCE) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.IRON_FENCE) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.IRON_TRAPDOOR) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.IRON_DOOR) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.IRON_DOOR_BLOCK) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.JUNGLE_FENCE) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.NETHER_FENCE) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.SPRUCE_FENCE) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.STAINED_GLASS_PANE) { nyet = true; } else if (world.getBlockAt(subX, subY, subZ).getType() == Material.THIN_GLASS) { nyet = true; }
    87 downloads
  4. 2017-09-21Sep 22, 2017
    46 downloads

Similar projects

Plugin →