Updated to 1.13

Backwards compatibility is also removed
This commit is contained in:
Sekwah 2018-07-23 03:02:42 +01:00
parent e3ff485b09
commit faf14757f8
15 changed files with 242 additions and 85 deletions

View File

@ -27,7 +27,7 @@ repositories {
// includeLibs just says to include the library in the final jar
dependencies {
compile "org.bukkit:bukkit:1.12.1-R0.1-SNAPSHOT"
compile "org.bukkit:bukkit:1.13-R0.1-SNAPSHOT"
}

View File

@ -0,0 +1,86 @@
# Advanced Portals Config
# To set this file back to its default state just delete it and reload the server or restart it!
# Set to true if you want the normal axes to work normally but the ones gived with /portals selector or wand will still work though
# It can be usefull if people with permission want to use an iron axe on a survival server
UseOnlyServerMadeAxe: false
# Preferably an item and not a block but it shouldnt matter
AxeItemId: IRON_AXE
# Will be implemented so you can give yourself the portal block and build manually with it so its easier to make portals with the portal block.
CanBuildPortalBlock: true
# Defines if portals protect themselves
PortalProtection: true
# How many blocks around the portals will be protected from griefing or destruction
PortalProtectionRadius: 5
# What the default trigger block is for portals if nothing is defined.
DefaultPortalTriggerBlock: PORTAL
# This stops all water flowing inside a portal area(can be disabled if something like world edit is handelling the water flow or you dont want it active)
# you want to
StopWaterFlow: true
# This must be a placeable block or it will not work and may even crash
ShowSelectionBlockID: RED_STAINED_GLASS
# WarpEffect
# 0 = disabled(no particles)
# 1 = Eye of ender explode effect(loads of portal particles)
# adding more soon and may create some custom ones
WarpParticles: 1
# WarpSound generally suggested to keep the same as warpeffect but can usually be used for just the sound and no particle effects
# 0 = disabled(no sound)
# 1 = Enderman Warp Sound
# adding more soon
WarpSound: 1
# In case you want to show the bungee attempting warp message
ShowBungeeWarpMessage: false
# This changes how long the show seletion lasts in seconds
ShowSelectionShowDuration: 10
# Where to display the message 0 = disabled(replaces PortalWarpMessages), 1 = in chat and 2 = action bar(1.8 and above only, anything lower will print the message that would
# generally on the action bar in the chat without a prefix or extra chat formatting)
WarpMessageDisplay: 2
# Use plugin name in the warp messages
UseWarpPrefix: true
# If this is true a custom prefix can be used, (not fully coded yet!!)
UseCustomPrefix: false
CustomPrefix: '&a[&eAdvancedPortals&a]'
CustomPrefixFail: '&c[&7AdvancedPortals&c]'
BlockSpectatorMode: false
PortalCooldown: 5 # How long after trying to enter a portal until the player can try to enter another. 0 or lower to deactivate.
ThrowbackAmount: 0.7 # How fast to throw them back, 0 or lower to disable throwback
# Letters are flags. Include them to activate. n always disables everything, remove if you want it to work.
# Lettering may not make too much sense but meh its useful. Examples are "ocpk" or "cop" (doesnt matter order)
#
# Remember enabling this means potentially admins could leave a portal lying around which could let them reop themselves.
# If you think this may be an issue use a permission plugin and specifically give the users you trust permissions.
#
# n Disabled none, best just put this to really make sure the fact none are here is specified. It disables any others too
# o Admin Heighten Enabled Permission advancedportals.createportal.commandlevel.op
# p Perm Heighten Enabled Permission advancedportals.createportal.commandlevel.perms
# c Console Heighten Enabled Permission advancedportals.createportal.commandlevel.console
# h Ops can create admin commands without special perms
# e Ops can create all perm commands without special perms
# k Ops can create console commands without special perms
#
CommandLevels: opchek

View File

@ -0,0 +1,7 @@
# ExampleDestination:
# world: it will be the world name
# pos:
# X:
# Y:
# Z:

View File

@ -0,0 +1,54 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.0.41
author: sekwah41
description: An advanced portals plugin for bukkit.
commands:
advancedportals:
description: The main command for the advanced portals
aliases: [portals, aportals, portal, ap]
usage: /<command>
destination:
description: Can be used to access portal destinations.
aliases: [desti]
usage: /<command>
permissions:
advancedportals.*:
description: Gives access to all commands
default: op
children:
advancedportals.createportal: true
advancedportals.portal: true
advancedportals.build: true
advancedportals.desti: true
advancedportals.createportal:
description: Allows you to create portals
default: op
advancedportals.createportal.commandlevel.*:
description: Gives access to all level raisers
default: false
children:
advancedportals.createportal.commandlevel.op: true
advancedportals.createportal.commandlevel.perms: true
advancedportals.createportal.commandlevel.console: true
advancedportals.createportal.commandlevel.op:
description: Allows you to increase the users level temporaily to op
default: false
advancedportals.createportal.commandlevel.perms:
description: Allows you to increase the users level temporaily to have all perms
default: false
advancedportals.createportal.commandlevel.console:
description: Executes command in the console
default: false
advancedportals.portal:
description: Allows use of portal commands
default: op
advancedportals.build:
description: Allows you to build in the portal regions
default: op
advancedportals.desti:
description: Gives access to all desti commands
default: op
advancedportals.warp.*:
description: Access to all warps (not really used tbh)
default: op

View File

@ -0,0 +1,19 @@
# ExamplePortal:
# world: it will be the world name
# triggerblock: LAVA # will only be used if the hastriggerblock is true and can be id or text
# pos1: # dont mess with the data here, if you do it may stop the portal from working.
# X:
# Y:
# Z:
# pos2:
# X:
# Y:
# Z:
# destination:
# issetpoint: true # if this was false point name would not be used and the coordinates would be saved here, it just adds more customisation.
# pointname: examplepoint # if issetpoint is false this wont be here and tppos will be.
# tppos:
# X:
# Y:
# Z:

View File

@ -700,7 +700,6 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
}
if (!hasTriggerBlock) {
autoComplete.add("triggerblock:");
autoComplete.addAll(this.blockMaterialList);
}
if (!hasDestination) {
autoComplete.add("destination:");
@ -725,6 +724,17 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
}
}
}
if(args[args.length-1].startsWith("triggerblock:")) {
autoComplete.addAll(this.blockMaterialList);
}
if(args[args.length-1].startsWith("desti:") || args[args.length-1].startsWith("destination:")) {
String tagStart = args[args.length-1].startsWith("desti:") ? "desti:" : "destination:";
ConfigAccessor destiConfig = new ConfigAccessor(plugin, "destinations.yml");
List<Object> destiObj = Arrays.asList(destiConfig.getConfig().getKeys(false).toArray());
for (Object object : destiObj) {
autoComplete.add(tagStart + object.toString());
}
}
Collections.sort(autoComplete);
for (Object result : autoComplete.toArray()) {
if (!result.toString().startsWith(args[args.length - 1])) {

View File

@ -3,13 +3,13 @@ package com.sekwah.advancedportals;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
public class Selection {
private static Material blockType = Material.STAINED_GLASS;
private static Material blockType = Material.RED_STAINED_GLASS;
private static int timeout = 10;
private static byte metadata = 14;
@SuppressWarnings("deprecation")
public static void loadData(AdvancedPortalsPlugin plugin) {
@ -18,17 +18,13 @@ public class Selection {
timeout = config.getConfig().getInt("ShowSelectionShowDuration");
String BlockID = config.getConfig().getString("ShowSelectionBlockID");
try {
blockType = Material.getMaterial(Integer.parseInt(BlockID));
} catch (Exception e) {
blockType = Material.getMaterial(BlockID);
}
blockType = Material.getMaterial(BlockID);
if (blockType == null) {
blockType = Material.STAINED_GLASS;
plugin.getLogger().warning("Material may be from old name format");
blockType = Material.RED_STAINED_GLASS;
}
metadata = (byte) config.getConfig().getInt("ShowSelectionBlockData");
}
@SuppressWarnings("deprecation")
@ -79,6 +75,8 @@ public class Selection {
final Location pos1 = new Location(player.getWorld(), LowX, LowY, LowZ);
final Location pos2 = new Location(player.getWorld(), HighX, HighY, HighZ);
BlockData blockData = blockType.createBlockData();
/*
* There are alot of for loops at the moment, when i find an easier way to do these other that a load of if statements
* then i will change it, but for now its the best way i can think of for doing this.
@ -86,51 +84,51 @@ public class Selection {
for (int x = LowX; x <= HighX; x++) {
Location loc = new Location(player.getWorld(), x, LowY, LowZ);
player.sendBlockChange(loc, blockType, metadata);
player.sendBlockChange(loc, blockData);
}
for (int x = LowX; x <= HighX; x++) {
Location loc = new Location(player.getWorld(), x, LowY, HighZ);
player.sendBlockChange(loc, blockType, metadata);
player.sendBlockChange(loc, blockData);
}
for (int z = LowZ; z <= HighZ; z++) {
Location loc = new Location(player.getWorld(), LowX, LowY, z);
player.sendBlockChange(loc, blockType, metadata);
player.sendBlockChange(loc, blockData);
}
for (int z = LowZ; z <= HighZ; z++) {
Location loc = new Location(player.getWorld(), HighX, LowY, z);
player.sendBlockChange(loc, blockType, metadata);
player.sendBlockChange(loc, blockData);
}
for (int y = LowY; y <= HighY; y++) {
Location loc = new Location(player.getWorld(), LowX, y, LowZ);
player.sendBlockChange(loc, blockType, metadata);
player.sendBlockChange(loc, blockData);
}
for (int y = LowY; y <= HighY; y++) {
Location loc = new Location(player.getWorld(), LowX, y, HighZ);
player.sendBlockChange(loc, blockType, metadata);
player.sendBlockChange(loc, blockData);
}
for (int y = LowY; y <= HighY; y++) {
Location loc = new Location(player.getWorld(), HighX, y, LowZ);
player.sendBlockChange(loc, blockType, metadata);
player.sendBlockChange(loc, blockData);
}
for (int y = LowY; y <= HighY; y++) {
Location loc = new Location(player.getWorld(), HighX, y, HighZ);
player.sendBlockChange(loc, blockType, metadata);
player.sendBlockChange(loc, blockData);
}
for (int x = LowX; x <= HighX; x++) {
Location loc = new Location(player.getWorld(), x, HighY, HighZ);
player.sendBlockChange(loc, blockType, metadata);
player.sendBlockChange(loc, blockData);
}
for (int x = LowX; x <= HighX; x++) {
Location loc = new Location(player.getWorld(), x, HighY, LowZ);
player.sendBlockChange(loc, blockType, metadata);
player.sendBlockChange(loc, blockData);
}
for (int z = LowZ; z <= HighZ; z++) {
Location loc = new Location(player.getWorld(), LowX, HighY, z);
player.sendBlockChange(loc, blockType, metadata);
player.sendBlockChange(loc, blockData);
}
for (int z = LowZ; z <= HighZ; z++) {
Location loc = new Location(player.getWorld(), HighX, HighY, z);
player.sendBlockChange(loc, blockType, metadata);
player.sendBlockChange(loc, blockData);
}

View File

@ -17,15 +17,15 @@ public class Destination {
private static AdvancedPortalsPlugin plugin;
private static boolean TeleportRiding = false;
public static int PortalMessagesDisplay = 0;
private static boolean TELEPORT_RIDING = false;
public static int PORTAL_MESSAGE_DISPLAY = 0;
public Destination(AdvancedPortalsPlugin plugin) {
Destination.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
TeleportRiding = config.getConfig().getBoolean("WarpRiddenEntity");
PortalMessagesDisplay = config.getConfig().getInt("WarpMessageDisplay");
TELEPORT_RIDING = config.getConfig().getBoolean("WarpRiddenEntity");
PORTAL_MESSAGE_DISPLAY = config.getConfig().getInt("WarpMessageDisplay");
}
// TODO add permissions for destinations.
@ -120,7 +120,7 @@ public class Destination {
Entity riding = player.getVehicle();
if (!c.isLoaded()) c.load();
if (player.getVehicle() != null && TeleportRiding) {
if (player.getVehicle() != null && TELEPORT_RIDING) {
riding.eject();
riding.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
@ -133,11 +133,11 @@ public class Destination {
WarpEffects.activateParticles(player);
WarpEffects.activateSound(player);
if (PortalMessagesDisplay == 1) {
if (PORTAL_MESSAGE_DISPLAY == 1) {
player.sendMessage("");
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7a You have been warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.");
player.sendMessage("");
} else if (PortalMessagesDisplay == 2) {
} else if (PORTAL_MESSAGE_DISPLAY == 2) {
plugin.compat.sendActionBarMessage("\u00A7aYou have warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.", player);
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.portals[portalId].portalName + ".destination").replaceAll("_", " ")
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/

View File

@ -73,7 +73,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
String message = PluginMessages.customPrefix + " \u00A77Destinations \u00A7c:\u00A7a";
List<Object> destiObj = Arrays.asList(config.getConfig().getKeys(false).toArray());
LinkedList<String> destis = new LinkedList<>();
for (Object object : destiObj.toArray()) {
for (Object object : destiObj) {
destis.add(object.toString());
}
Collections.sort(destis);
@ -122,13 +122,12 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
autoComplete.add(string);
}
}
if (sender.hasPermission("advancedportals.desti") | sender.hasPermission("advancedportals.createportal")) {
if (args.length == 1) {
if (args.length == 1) {
if (sender.hasPermission("advancedportals.desti") | sender.hasPermission("advancedportals.createportal")) {
autoComplete.addAll(Arrays.asList("create", "remove", "help"));
} else if (args[0].toLowerCase().equals("create")) {
}
autoComplete.add("warp");
}
autoComplete.add("warp");
Collections.sort(autoComplete);
for (Object result : autoComplete.toArray()) {
if (!result.toString().startsWith(args[args.length - 1])) {

View File

@ -21,10 +21,10 @@ public class WarpEffects {
plugin = pluginTemp;
sounds[0] = findSound(plugin, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT");
//sounds[0] = findSound(plugin, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT");
sounds[0] = Sound.ENTITY_ENDERMAN_TELEPORT;
// SPIGOT STOP CHANGING THE BLOODY NAMES! we already knew what an explosion was...
sounds[1] = findSound(plugin, "ENTITY_GENERIC_EXPLODE", "EXPLODE");
sounds[1] = Sound.ENTITY_GENERIC_EXPLODE;
}
@ -49,7 +49,7 @@ public class WarpEffects {
Location loc = player.getLocation();
World world = player.getWorld();
switch (plugin.getSettings().getCurrentWarpParticles()){
case 1:
case 1:
for(int i = 0; i < 10; i++){
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
}
@ -59,7 +59,7 @@ public class WarpEffects {
}
default: break;
}
}
public static void activateSound(Player player) {

View File

@ -10,7 +10,9 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Rotatable;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -46,11 +48,7 @@ public class Listeners implements Listener {
WandMaterial = Material.IRON_AXE;
}
else{
try {
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
} catch (Exception e) {
WandMaterial = Material.getMaterial(ItemID);
}
WandMaterial = Material.getMaterial(ItemID);
}
@ -65,11 +63,7 @@ public class Listeners implements Listener {
String ItemID = config.getConfig().getString("AxeItemId");
try {
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
} catch (Exception e) {
WandMaterial = Material.getMaterial(ItemID);
}
WandMaterial = Material.getMaterial(ItemID);
}
@EventHandler
@ -117,7 +111,7 @@ public class Listeners implements Listener {
Location eyeLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ());
for (AdvancedPortal portal : Portal.portals) {
if (Portal.locationInPortalTrigger(portal, loc) || Portal.locationInPortalTrigger(portal, eyeLoc)) {
if (portal.getTrigger().equals(Material.PORTAL)) {
if (portal.getTrigger().equals(Material.NETHER_PORTAL)) {
if (player.getGameMode().equals(GameMode.CREATIVE)) {
player.setMetadata("hasWarped", new FixedMetadataValue(plugin, true));
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveWarpData(player), 10);
@ -263,12 +257,15 @@ public class Listeners implements Listener {
}
} else if (checkItemForName(event.getItem()) && event.getItem().getItemMeta().getDisplayName().equals("\u00A75Portal Block Placer") &&
event.getAction() == Action.LEFT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.PORTAL) {
Block block = event.getClickedBlock();
if (block.getData() == 1) {
block.setData((byte) 2);
} else {
block.setData((byte) 1);
event.getAction() == Action.LEFT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.NETHER_PORTAL) {
BlockData block = event.getClickedBlock().getBlockData();
if(block instanceof Rotatable) {
Rotatable rotatable = (Rotatable) block;
if (rotatable.getRotation() == BlockFace.NORTH) {
rotatable.setRotation(BlockFace.EAST);
} else {
rotatable.setRotation(BlockFace.NORTH);
}
}
event.setCancelled(true);
}

View File

@ -40,10 +40,10 @@ public class PortalPlacer implements Listener {
if(name == null) return;
if (name.equals("\u00A75Portal Block Placer")){
event.getBlockPlaced().setType(Material.PORTAL);
event.getBlockPlaced().setType(Material.NETHER_PORTAL);
}
else if (name.equals("\u00A78End Portal Block Placer")){
event.getBlockPlaced().setType(Material.ENDER_PORTAL);
event.getBlockPlaced().setType(Material.NETHER_PORTAL);
}
else if (name.equals("\u00A78Gateway Block Placer")){
event.getBlockPlaced().setType(Material.END_GATEWAY);
@ -56,7 +56,7 @@ public class PortalPlacer implements Listener {
public void onBlockPhysics(BlockPhysicsEvent event) {
Block block = event.getBlock();
Material material = block.getType();
if (material == Material.PORTAL && Portal.inPortalRegion(block.getLocation(), Portal.getPortalProtectionRadius()))
if (material == Material.NETHER_PORTAL && Portal.inPortalRegion(block.getLocation(), Portal.getPortalProtectionRadius()))
event.setCancelled(true);
}
}

View File

@ -74,7 +74,7 @@ public class Portal {
ConfigurationSection portalConfigSection = portalData.getConfig().getConfigurationSection(portal.toString());
Material blockType = Material.PORTAL;
Material blockType = Material.NETHER_PORTAL;
String BlockID = portalConfigSection.getString("triggerblock");
try {
@ -85,7 +85,7 @@ public class Portal {
}
if (blockType == null) {
blockType = Material.PORTAL;
blockType = Material.NETHER_PORTAL;
}
ConfigurationSection portalArgsConf = portalConfigSection.getConfigurationSection("portalArgs");
@ -279,21 +279,13 @@ public class Portal {
Material triggerBlockType;
String BlockID = config.getConfig().getString("DefaultPortalTriggerBlock");
try {
triggerBlockType = Material.getMaterial(Integer.parseInt(BlockID));
} catch (Exception e) {
triggerBlockType = Material.getMaterial(BlockID);
}
triggerBlockType = Material.getMaterial(BlockID);
if (triggerBlockType == null) {
triggerBlockType = Material.PORTAL;
triggerBlockType = Material.NETHER_PORTAL;
}
// TODO add a for loop which scans through the addArgs and adds them to the portalData so that the application can use them
String result = create(pos1, pos2, name, destination, triggerBlockType, serverName, extraData);
return result;
return create(pos1, pos2, name, destination, triggerBlockType, serverName, extraData);
}
public static void redefine(Location pos1, Location pos2, String name) {
@ -389,7 +381,7 @@ public class Portal {
}
String permission = portal.getArg("permission");
/*if((permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())){*/
/*if((permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())){*/
// 3 checks, 1st is if it doesnt need perms. 2nd is if it does do they have it. And third is are they op.
if (!(permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())) {
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c You do not have permission to use this portal!");
@ -488,7 +480,7 @@ public class Portal {
}
private static void failSound(Player player, AdvancedPortal portal) {
if(!(portal.getTrigger() == Material.PORTAL && player.getGameMode() == GameMode.CREATIVE)){
if(!(portal.getTrigger() == Material.NETHER_PORTAL && player.getGameMode() == GameMode.CREATIVE)){
player.playSound(player.getLocation(), portalSound, 0.5f, new Random().nextFloat() * 0.4F + 0.8F);
}
}

View File

@ -28,8 +28,7 @@ DefaultPortalTriggerBlock: PORTAL
StopWaterFlow: true
# This must be a placeable block or it will not work and may even crash
ShowSelectionBlockID: STAINED_GLASS
ShowSelectionBlockData: 14
ShowSelectionBlockID: RED_STAINED_GLASS
# WarpEffect
# 0 = disabled(no particles)
@ -50,11 +49,6 @@ ShowBungeeWarpMessage: false
ShowSelectionShowDuration: 10
# If a player is riding a entity, warp the entity too?(unless its a bungee portal or any non teleporting portal)
WarpRiddenEntity: true
# Where to display the message 0 = disabled(replaces PortalWarpMessages), 1 = in chat and 2 = action bar(1.8 and above only, anything lower will print the message that would
# generally on the action bar in the chat without a prefix or extra chat formatting)
WarpMessageDisplay: 2

View File

@ -1,8 +1,9 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.0.41
version: 0.0.42
author: sekwah41
description: An advanced portals plugin for bukkit.
api-version: 1.13
commands:
advancedportals:
description: The main command for the advanced portals