Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
8a5c094ce1 | |||
5e79df9f44 | |||
a3ed1058e6 | |||
f70ba24e95 | |||
f6438eb872 | |||
2bf5422b2a | |||
f95ee0b85d | |||
1e06e0e01d | |||
bddf8c55d5 | |||
05a5fb2160 | |||
d9f535cd07 | |||
62952611b8 |
15
README.md
15
README.md
@ -306,6 +306,7 @@ folders:
|
|||||||
gates:
|
gates:
|
||||||
maxGatesEachNetwork - If non-zero, will define the maximum amount of gates allowed on any network.
|
maxGatesEachNetwork - If non-zero, will define the maximum amount of gates allowed on any network.
|
||||||
defaultGateNetwork - The default gate network
|
defaultGateNetwork - The default gate network
|
||||||
|
exitVelocity - The velocity to give players exiting stargates, relative to the entry velocity (1 = same as entry velocity)
|
||||||
cosmetic:
|
cosmetic:
|
||||||
rememberDestination - Whether to set the first destination as the last used destination for all gates
|
rememberDestination - Whether to set the first destination as the last used destination for all gates
|
||||||
sortNetworkDestinations - If true, network lists will be sorted alphabetically.
|
sortNetworkDestinations - If true, network lists will be sorted alphabetically.
|
||||||
@ -396,6 +397,20 @@ portalInfoServer=Server: %server%
|
|||||||
|
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
#### \[Version 0.9.3.3] EpicKnarvik97 fork
|
||||||
|
|
||||||
|
- Prevents Zombified Piglins from randomly spawning at Stargates
|
||||||
|
|
||||||
|
#### \[Version 0.9.3.2] EpicKnarvik97 fork
|
||||||
|
|
||||||
|
- Adds a config option to set the exit velocity of any players exiting a stargate
|
||||||
|
- Adjusts vehicle teleportation a bit to prevent passengers' exit rotation from being wrong
|
||||||
|
- Improves the checking for buggy double-clicks on non-button blocks
|
||||||
|
|
||||||
|
#### \[Version 0.9.3.1] EpicKnarvik97 fork
|
||||||
|
|
||||||
|
- Ignores the type of air when checking if a stargate is valid
|
||||||
|
|
||||||
#### \[Version 0.9.3.0] EpicKnarvik97 fork
|
#### \[Version 0.9.3.0] EpicKnarvik97 fork
|
||||||
|
|
||||||
- Adds support for RGB colors (use hex color codes)
|
- Adds support for RGB colors (use hex color codes)
|
||||||
|
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>net.knarcraft</groupId>
|
<groupId>net.knarcraft</groupId>
|
||||||
<artifactId>Stargate</artifactId>
|
<artifactId>Stargate</artifactId>
|
||||||
<version>0.9.3.0</version>
|
<version>0.9.3.3</version>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
|
@ -10,6 +10,7 @@ import net.knarcraft.stargate.container.BlockChangeRequest;
|
|||||||
import net.knarcraft.stargate.container.ChunkUnloadRequest;
|
import net.knarcraft.stargate.container.ChunkUnloadRequest;
|
||||||
import net.knarcraft.stargate.listener.BlockEventListener;
|
import net.knarcraft.stargate.listener.BlockEventListener;
|
||||||
import net.knarcraft.stargate.listener.EntityEventListener;
|
import net.knarcraft.stargate.listener.EntityEventListener;
|
||||||
|
import net.knarcraft.stargate.listener.EntitySpawnListener;
|
||||||
import net.knarcraft.stargate.listener.PlayerEventListener;
|
import net.knarcraft.stargate.listener.PlayerEventListener;
|
||||||
import net.knarcraft.stargate.listener.PluginEventListener;
|
import net.knarcraft.stargate.listener.PluginEventListener;
|
||||||
import net.knarcraft.stargate.listener.PortalEventListener;
|
import net.knarcraft.stargate.listener.PortalEventListener;
|
||||||
@ -388,6 +389,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
pluginManager.registerEvents(new WorldEventListener(), this);
|
pluginManager.registerEvents(new WorldEventListener(), this);
|
||||||
pluginManager.registerEvents(new PluginEventListener(this), this);
|
pluginManager.registerEvents(new PluginEventListener(this), this);
|
||||||
pluginManager.registerEvents(new TeleportEventListener(), this);
|
pluginManager.registerEvents(new TeleportEventListener(), this);
|
||||||
|
pluginManager.registerEvents(new EntitySpawnListener(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,6 +90,15 @@ public class CommandConfig implements CommandExecutor {
|
|||||||
configuration.set(selectedOption.getConfigNode(), intValue);
|
configuration.set(selectedOption.getConfigNode(), intValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case DOUBLE -> {
|
||||||
|
Double doubleValue = getDouble(commandSender, selectedOption, value);
|
||||||
|
if (doubleValue == null) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
Stargate.getStargateConfig().getConfigOptionsReference().put(selectedOption, doubleValue);
|
||||||
|
configuration.set(selectedOption.getConfigNode(), doubleValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
case STRING -> {
|
case STRING -> {
|
||||||
updateStringConfigValue(selectedOption, commandSender, value);
|
updateStringConfigValue(selectedOption, commandSender, value);
|
||||||
configuration.set(selectedOption.getConfigNode(), value);
|
configuration.set(selectedOption.getConfigNode(), value);
|
||||||
@ -314,6 +323,30 @@ public class CommandConfig implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a double from a string
|
||||||
|
*
|
||||||
|
* @param commandSender <p>The command sender that sent the config command</p>
|
||||||
|
* @param selectedOption <p>The option the command sender is trying to change</p>
|
||||||
|
* @param value <p>The value given</p>
|
||||||
|
* @return <p>A double, or null if it was invalid</p>
|
||||||
|
*/
|
||||||
|
private Double getDouble(CommandSender commandSender, ConfigOption selectedOption, String value) {
|
||||||
|
try {
|
||||||
|
double doubleValue = Double.parseDouble(value);
|
||||||
|
|
||||||
|
if (selectedOption == ConfigOption.EXIT_VELOCITY && doubleValue < 0) {
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "This config option cannot be negative.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return doubleValue;
|
||||||
|
} catch (NumberFormatException exception) {
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "Invalid number given");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reloads the config if necessary
|
* Reloads the config if necessary
|
||||||
*
|
*
|
||||||
|
@ -21,16 +21,17 @@ public class ConfigTabCompleter implements TabCompleter {
|
|||||||
|
|
||||||
private List<String> signTypes;
|
private List<String> signTypes;
|
||||||
private List<String> booleans;
|
private List<String> booleans;
|
||||||
private List<String> numbers;
|
private List<String> integers;
|
||||||
private List<String> chatColors;
|
private List<String> chatColors;
|
||||||
private List<String> languages;
|
private List<String> languages;
|
||||||
private List<String> extendedColors;
|
private List<String> extendedColors;
|
||||||
|
private List<String> doubles;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
|
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
|
||||||
@NotNull String[] args) {
|
@NotNull String[] args) {
|
||||||
if (signTypes == null || booleans == null || numbers == null || chatColors == null || languages == null) {
|
if (signTypes == null || booleans == null || integers == null || chatColors == null || languages == null) {
|
||||||
initializeAutoCompleteLists();
|
initializeAutoCompleteLists();
|
||||||
}
|
}
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
@ -104,7 +105,16 @@ public class ConfigTabCompleter implements TabCompleter {
|
|||||||
//If the config value is an integer, display some valid numbers
|
//If the config value is an integer, display some valid numbers
|
||||||
if (selectedOption.getDataType() == OptionDataType.INTEGER) {
|
if (selectedOption.getDataType() == OptionDataType.INTEGER) {
|
||||||
if (typedText.trim().isEmpty()) {
|
if (typedText.trim().isEmpty()) {
|
||||||
return numbers;
|
return integers;
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//If the config value is a double, display some valid numbers
|
||||||
|
if (selectedOption.getDataType() == OptionDataType.DOUBLE) {
|
||||||
|
if (typedText.trim().isEmpty()) {
|
||||||
|
return doubles;
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
@ -164,9 +174,9 @@ public class ConfigTabCompleter implements TabCompleter {
|
|||||||
booleans.add("true");
|
booleans.add("true");
|
||||||
booleans.add("false");
|
booleans.add("false");
|
||||||
|
|
||||||
numbers = new ArrayList<>();
|
integers = new ArrayList<>();
|
||||||
numbers.add("0");
|
integers.add("0");
|
||||||
numbers.add("5");
|
integers.add("5");
|
||||||
|
|
||||||
signTypes = new ArrayList<>();
|
signTypes = new ArrayList<>();
|
||||||
for (Material material : Material.values()) {
|
for (Material material : Material.values()) {
|
||||||
@ -181,6 +191,12 @@ public class ConfigTabCompleter implements TabCompleter {
|
|||||||
extendedColors = new ArrayList<>(chatColors);
|
extendedColors = new ArrayList<>(chatColors);
|
||||||
extendedColors.add("default");
|
extendedColors.add("default");
|
||||||
extendedColors.add("inverted");
|
extendedColors.add("inverted");
|
||||||
|
|
||||||
|
doubles = new ArrayList<>();
|
||||||
|
doubles.add("5");
|
||||||
|
doubles.add("1");
|
||||||
|
doubles.add("0.5");
|
||||||
|
doubles.add("0.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,8 +156,12 @@ public enum ConfigOption {
|
|||||||
/**
|
/**
|
||||||
* Whether to alert admins about new updates
|
* Whether to alert admins about new updates
|
||||||
*/
|
*/
|
||||||
ADMIN_UPDATE_ALERT("adminUpdateAlert", "Whether to alert admins about new plugin updates", true);
|
ADMIN_UPDATE_ALERT("adminUpdateAlert", "Whether to alert admins about new plugin updates", true),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The velocity of players exiting a stargate, relative to the entry velocity
|
||||||
|
*/
|
||||||
|
EXIT_VELOCITY("gates.exitVelocity", "The velocity of players exiting stargates, relative to the entry velocity", 0.1D);
|
||||||
|
|
||||||
private final String configNode;
|
private final String configNode;
|
||||||
private final String description;
|
private final String description;
|
||||||
@ -184,6 +188,8 @@ public enum ConfigOption {
|
|||||||
this.dataType = OptionDataType.BOOLEAN;
|
this.dataType = OptionDataType.BOOLEAN;
|
||||||
} else if (defaultValue instanceof Integer) {
|
} else if (defaultValue instanceof Integer) {
|
||||||
this.dataType = OptionDataType.INTEGER;
|
this.dataType = OptionDataType.INTEGER;
|
||||||
|
} else if (defaultValue instanceof Double) {
|
||||||
|
this.dataType = OptionDataType.DOUBLE;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unknown config data type encountered: " + defaultValue);
|
throw new IllegalArgumentException("Unknown config data type encountered: " + defaultValue);
|
||||||
}
|
}
|
||||||
|
@ -6,17 +6,28 @@ package net.knarcraft.stargate.config;
|
|||||||
public enum OptionDataType {
|
public enum OptionDataType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The data type for the option is a String
|
* The data type if the option is a String
|
||||||
*/
|
*/
|
||||||
STRING,
|
STRING,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The data type for the option is a Boolean
|
* The data type if the option is a Boolean
|
||||||
*/
|
*/
|
||||||
BOOLEAN,
|
BOOLEAN,
|
||||||
STRING_LIST,
|
|
||||||
/**
|
/**
|
||||||
* The data type for the option is an Integer
|
* The data type if the option is a string list
|
||||||
*/
|
*/
|
||||||
INTEGER
|
STRING_LIST,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The data type if the option is an Integer
|
||||||
|
*/
|
||||||
|
INTEGER,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The data type if the option is a double
|
||||||
|
*/
|
||||||
|
DOUBLE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -358,6 +358,7 @@ public final class StargateConfig {
|
|||||||
}
|
}
|
||||||
case BOOLEAN -> optionValue = newConfig.getBoolean(configNode);
|
case BOOLEAN -> optionValue = newConfig.getBoolean(configNode);
|
||||||
case INTEGER -> optionValue = newConfig.getInt(configNode);
|
case INTEGER -> optionValue = newConfig.getInt(configNode);
|
||||||
|
case DOUBLE -> optionValue = newConfig.getDouble(configNode);
|
||||||
default -> throw new IllegalArgumentException("Invalid config data type encountered");
|
default -> throw new IllegalArgumentException("Invalid config data type encountered");
|
||||||
}
|
}
|
||||||
configOptions.put(option, optionValue);
|
configOptions.put(option, optionValue);
|
||||||
|
@ -179,6 +179,15 @@ public final class StargateGateConfig {
|
|||||||
return (String) configOptions.get(ConfigOption.DEFAULT_GATE_NETWORK);
|
return (String) configOptions.get(ConfigOption.DEFAULT_GATE_NETWORK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the exit velocity of players using stargates, relative to the entry velocity
|
||||||
|
*
|
||||||
|
* @return <p>The relative exit velocity</p>
|
||||||
|
*/
|
||||||
|
public double getExitVelocity() {
|
||||||
|
return (double) configOptions.get(ConfigOption.EXIT_VELOCITY);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all config values related to gates
|
* Loads all config values related to gates
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package net.knarcraft.stargate.listener;
|
||||||
|
|
||||||
|
import net.knarcraft.stargate.Stargate;
|
||||||
|
import net.knarcraft.stargate.portal.PortalHandler;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A listener that listens for any relevant events causing entities to spawn
|
||||||
|
*/
|
||||||
|
public class EntitySpawnListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
|
//Prevent Zombified Piglins and other creatures form spawning at stargates
|
||||||
|
if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.NETHER_PORTAL) {
|
||||||
|
if (PortalHandler.getByEntrance(event.getLocation()) != null) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
Stargate.debug("EntitySpawnListener", "Prevented creature from spawning at Stargate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -34,14 +34,16 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This listener listens to any player-related events related to stargates
|
* This listener listens to any player-related events related to stargates
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class PlayerEventListener implements Listener {
|
public class PlayerEventListener implements Listener {
|
||||||
|
|
||||||
private static long eventTime;
|
private static final Map<Player, Long> previousEventTimes = new HashMap<>();
|
||||||
private static PlayerInteractEvent previousEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event handler handles detection of any player teleporting through a bungee gate
|
* This event handler handles detection of any player teleporting through a bungee gate
|
||||||
@ -295,7 +297,7 @@ public class PlayerEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Prevent a double click caused by a Spigot bug
|
//Prevent a double click caused by a Spigot bug
|
||||||
if (clickIsBug(event, block)) {
|
if (clickIsBug(event.getPlayer(), block)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,19 +368,17 @@ public class PlayerEventListener implements Listener {
|
|||||||
* immediately, or causing portal information printing twice. This fix should detect the bug without breaking
|
* immediately, or causing portal information printing twice. This fix should detect the bug without breaking
|
||||||
* clicking once the bug is fixed.</p>
|
* clicking once the bug is fixed.</p>
|
||||||
*
|
*
|
||||||
* @param event <p>The event causing the right click</p>
|
* @param player <p>The player performing the right-click</p>
|
||||||
* @param block <p>The block to check</p>
|
* @param block <p>The block to check</p>
|
||||||
* @return <p>True if the click is a bug and should be cancelled</p>
|
* @return <p>True if the click is a bug and should be cancelled</p>
|
||||||
*/
|
*/
|
||||||
private boolean clickIsBug(PlayerInteractEvent event, Block block) {
|
private boolean clickIsBug(Player player, Block block) {
|
||||||
if (previousEvent != null &&
|
Long previousEventTime = previousEventTimes.get(player);
|
||||||
event.getPlayer() == previousEvent.getPlayer() && eventTime + 15 > System.currentTimeMillis()) {
|
if (previousEventTime != null && previousEventTime + 50 > System.currentTimeMillis()) {
|
||||||
previousEvent = null;
|
previousEventTimes.put(player, null);
|
||||||
eventTime = 0;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
previousEvent = event;
|
previousEventTimes.put(player, System.currentTimeMillis());
|
||||||
eventTime = System.currentTimeMillis();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ public class Gate {
|
|||||||
Material type = topLeft.getRelativeLocation(entranceVector, yaw).getType();
|
Material type = topLeft.getRelativeLocation(entranceVector, yaw).getType();
|
||||||
|
|
||||||
//Ignore entrance if it's air or water, and we're creating a new gate
|
//Ignore entrance if it's air or water, and we're creating a new gate
|
||||||
if (onCreate && (type == Material.AIR || type == Material.WATER)) {
|
if (onCreate && (type.isAir() || type == Material.WATER)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,9 +3,12 @@ package net.knarcraft.stargate.portal.teleporter;
|
|||||||
import net.knarcraft.stargate.Stargate;
|
import net.knarcraft.stargate.Stargate;
|
||||||
import net.knarcraft.stargate.event.StargatePlayerPortalEvent;
|
import net.knarcraft.stargate.event.StargatePlayerPortalEvent;
|
||||||
import net.knarcraft.stargate.portal.Portal;
|
import net.knarcraft.stargate.portal.Portal;
|
||||||
|
import net.knarcraft.stargate.utility.DirectionHelper;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The portal teleporter takes care of the actual portal teleportation for any players
|
* The portal teleporter takes care of the actual portal teleportation for any players
|
||||||
@ -32,6 +35,7 @@ public class PlayerTeleporter extends Teleporter {
|
|||||||
* @param event <p>The player move event triggering the event</p>
|
* @param event <p>The player move event triggering the event</p>
|
||||||
*/
|
*/
|
||||||
public void teleport(Portal origin, PlayerMoveEvent event) {
|
public void teleport(Portal origin, PlayerMoveEvent event) {
|
||||||
|
double velocity = player.getVelocity().length();
|
||||||
Location traveller = player.getLocation();
|
Location traveller = player.getLocation();
|
||||||
Location exit = getExit(player, traveller);
|
Location exit = getExit(player, traveller);
|
||||||
|
|
||||||
@ -56,9 +60,16 @@ public class PlayerTeleporter extends Teleporter {
|
|||||||
if (event == null) {
|
if (event == null) {
|
||||||
player.teleport(exit);
|
player.teleport(exit);
|
||||||
} else {
|
} else {
|
||||||
//The new method to teleport in a move event is set the "to" field.
|
//Set the exit location of the event
|
||||||
event.setTo(exit);
|
event.setTo(exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Set the velocity of the teleported player after the teleportation is finished
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Stargate.getInstance(), () -> {
|
||||||
|
Vector newVelocityDirection = DirectionHelper.getDirectionVectorFromYaw(portal.getYaw());
|
||||||
|
Vector newVelocity = newVelocityDirection.multiply(velocity * Stargate.getGateConfig().getExitVelocity());
|
||||||
|
player.setVelocity(newVelocity);
|
||||||
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +59,7 @@ public abstract class Teleporter {
|
|||||||
}
|
}
|
||||||
float newYaw = (portal.getYaw() + adjust) % 360;
|
float newYaw = (portal.getYaw() + adjust) % 360;
|
||||||
Stargate.debug("Portal::adjustRotation", "Setting exit yaw to " + newYaw);
|
Stargate.debug("Portal::adjustRotation", "Setting exit yaw to " + newYaw);
|
||||||
exit.setYaw(newYaw);
|
exit.setDirection(DirectionHelper.getDirectionVectorFromYaw(newYaw));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,7 +141,7 @@ public abstract class Teleporter {
|
|||||||
if (entitySize > 1) {
|
if (entitySize > 1) {
|
||||||
double entityOffset;
|
double entityOffset;
|
||||||
if (portal.getOptions().isAlwaysOn()) {
|
if (portal.getOptions().isAlwaysOn()) {
|
||||||
entityOffset = entityBoxSize / 2D;
|
entityOffset = (entityBoxSize / 2D);
|
||||||
} else {
|
} else {
|
||||||
entityOffset = (entitySize / 2D) - 1;
|
entityOffset = (entitySize / 2D) - 1;
|
||||||
}
|
}
|
||||||
@ -217,8 +217,8 @@ public abstract class Teleporter {
|
|||||||
protected void loadChunks() {
|
protected void loadChunks() {
|
||||||
for (Chunk chunk : getChunksToLoad()) {
|
for (Chunk chunk : getChunksToLoad()) {
|
||||||
chunk.addPluginChunkTicket(Stargate.getInstance());
|
chunk.addPluginChunkTicket(Stargate.getInstance());
|
||||||
//Allow the chunk to unload after 3 seconds
|
//Allow the chunk to unload after 10 seconds
|
||||||
Stargate.addChunkUnloadRequest(new ChunkUnloadRequest(chunk, 3000L));
|
Stargate.addChunkUnloadRequest(new ChunkUnloadRequest(chunk, 10000L));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ public class VehicleTeleporter extends EntityTeleporter {
|
|||||||
private void teleportLivingVehicle(Location exit, List<Entity> passengers, Portal origin) {
|
private void teleportLivingVehicle(Location exit, List<Entity> passengers, Portal origin) {
|
||||||
teleportingVehicle.eject();
|
teleportingVehicle.eject();
|
||||||
teleportingVehicle.teleport(exit);
|
teleportingVehicle.teleport(exit);
|
||||||
handleVehiclePassengers(passengers, teleportingVehicle, 2, origin);
|
handleVehiclePassengers(passengers, teleportingVehicle, 2, origin, exit.getDirection());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -194,7 +194,7 @@ public class VehicleTeleporter extends EntityTeleporter {
|
|||||||
teleportingVehicle.remove();
|
teleportingVehicle.remove();
|
||||||
//Set rotation, add passengers and restore velocity
|
//Set rotation, add passengers and restore velocity
|
||||||
newVehicle.setRotation(exit.getYaw(), exit.getPitch());
|
newVehicle.setRotation(exit.getYaw(), exit.getPitch());
|
||||||
handleVehiclePassengers(passengers, newVehicle, 1, origin);
|
handleVehiclePassengers(passengers, newVehicle, 1, origin, exit.getDirection());
|
||||||
scheduler.scheduleSyncDelayedTask(Stargate.getInstance(), () -> newVehicle.setVelocity(newVelocity), 1);
|
scheduler.scheduleSyncDelayedTask(Stargate.getInstance(), () -> newVehicle.setVelocity(newVelocity), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,8 +205,9 @@ public class VehicleTeleporter extends EntityTeleporter {
|
|||||||
* @param vehicle <p>The vehicle the passengers should be put into</p>
|
* @param vehicle <p>The vehicle the passengers should be put into</p>
|
||||||
* @param delay <p>The amount of milliseconds to wait before adding the vehicle passengers</p>
|
* @param delay <p>The amount of milliseconds to wait before adding the vehicle passengers</p>
|
||||||
* @param origin <p>The portal the vehicle teleported from</p>
|
* @param origin <p>The portal the vehicle teleported from</p>
|
||||||
|
* @param exitRotation <p>The rotation of any passengers exiting the stargate</p>
|
||||||
*/
|
*/
|
||||||
private void handleVehiclePassengers(List<Entity> passengers, Vehicle vehicle, long delay, Portal origin) {
|
private void handleVehiclePassengers(List<Entity> passengers, Vehicle vehicle, long delay, Portal origin, Vector exitRotation) {
|
||||||
for (Entity passenger : passengers) {
|
for (Entity passenger : passengers) {
|
||||||
passenger.eject();
|
passenger.eject();
|
||||||
scheduler.scheduleSyncDelayedTask(Stargate.getInstance(), () -> {
|
scheduler.scheduleSyncDelayedTask(Stargate.getInstance(), () -> {
|
||||||
@ -214,7 +215,7 @@ public class VehicleTeleporter extends EntityTeleporter {
|
|||||||
//Teleport any creatures leashed by the player in a 15-block range
|
//Teleport any creatures leashed by the player in a 15-block range
|
||||||
teleportLeashedCreatures(player, origin);
|
teleportLeashedCreatures(player, origin);
|
||||||
}
|
}
|
||||||
teleportAndAddPassenger(vehicle, passenger);
|
teleportAndAddPassenger(vehicle, passenger, exitRotation);
|
||||||
}, delay);
|
}, delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,9 +228,10 @@ public class VehicleTeleporter extends EntityTeleporter {
|
|||||||
*
|
*
|
||||||
* @param targetVehicle <p>The vehicle to add the passenger to</p>
|
* @param targetVehicle <p>The vehicle to add the passenger to</p>
|
||||||
* @param passenger <p>The passenger to teleport and add</p>
|
* @param passenger <p>The passenger to teleport and add</p>
|
||||||
|
* @param exitDirection <p>The direction of any passengers exiting the stargate</p>
|
||||||
*/
|
*/
|
||||||
private void teleportAndAddPassenger(Vehicle targetVehicle, Entity passenger) {
|
private void teleportAndAddPassenger(Vehicle targetVehicle, Entity passenger, Vector exitDirection) {
|
||||||
if (!passenger.teleport(targetVehicle.getLocation())) {
|
if (!passenger.teleport(targetVehicle.getLocation().clone().setDirection(exitDirection))) {
|
||||||
Stargate.debug("handleVehiclePassengers", "Failed to teleport passenger");
|
Stargate.debug("handleVehiclePassengers", "Failed to teleport passenger");
|
||||||
}
|
}
|
||||||
if (!targetVehicle.addPassenger(passenger)) {
|
if (!targetVehicle.addPassenger(passenger)) {
|
||||||
|
@ -15,6 +15,8 @@ gates:
|
|||||||
maxGatesEachNetwork: 0
|
maxGatesEachNetwork: 0
|
||||||
# defaultGateNetwork - The default gate network
|
# defaultGateNetwork - The default gate network
|
||||||
defaultGateNetwork: central
|
defaultGateNetwork: central
|
||||||
|
# exitVelocity - The velocity to give players exiting stargates, relative to the entry velocity
|
||||||
|
exitVelocity: 0.1
|
||||||
cosmetic:
|
cosmetic:
|
||||||
# rememberDestination - Whether to remember the cursor location between uses
|
# rememberDestination - Whether to remember the cursor location between uses
|
||||||
rememberDestination: false
|
rememberDestination: false
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: Stargate
|
name: Stargate
|
||||||
main: net.knarcraft.stargate.Stargate
|
main: net.knarcraft.stargate.Stargate
|
||||||
version: 0.9.3.0
|
version: 0.9.3.3
|
||||||
description: Stargate mod for Bukkit Revived
|
description: Stargate mod for Bukkit Revived
|
||||||
author: EpicKnarvik97
|
author: EpicKnarvik97
|
||||||
authors: [ Drakia, PseudoKnight, EpicKnarvik97 ]
|
authors: [ Drakia, PseudoKnight, EpicKnarvik97 ]
|
||||||
|
Reference in New Issue
Block a user