mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-07-01 23:36:18 +00:00
new RTPOnDeath option for world configuration
This commit is contained in:
parent
2350b6aca2
commit
418ef2a717
@ -0,0 +1,22 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
public class Death {
|
||||
|
||||
static void respawnEvent(PlayerRespawnEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
WorldPlayer worldPlayer = HelperRTP.getPlayerWorld(new RTPSetupInformation(
|
||||
p.getWorld(),
|
||||
p, p, false
|
||||
));
|
||||
if (worldPlayer.getRTPOnDeath()) {
|
||||
HelperRTP.tp(p, p, p.getWorld(), null, RTP_TYPE.FORCED, true, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,10 +6,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@ -65,4 +62,9 @@ public class EventListener implements Listener {
|
||||
private void worldLoad(WorldLoadEvent e) {
|
||||
worldLoad.load(e);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onRespawn(PlayerRespawnEvent e) {
|
||||
Death.respawnEvent(e);
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ import java.util.Map;
|
||||
|
||||
public class RTP {
|
||||
|
||||
final RTPTeleport teleport = new RTPTeleport();
|
||||
@Getter final RTPTeleport teleport = new RTPTeleport();
|
||||
//Cache
|
||||
public final HashMap<String, String> overriden = new HashMap<>();
|
||||
@Getter List<String> disabledWorlds, blockList;
|
||||
@ -35,10 +35,6 @@ public class RTP {
|
||||
@Getter private final HashMap<String, RTPWorld> RTPworldLocations = new HashMap<>();
|
||||
@Getter private final HashMap<String, PermissionGroup> permissionGroups = new HashMap<>();
|
||||
|
||||
public RTPTeleport getTeleport() {
|
||||
return teleport;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||
disabledWorlds = config.getStringList("DisabledWorlds");
|
||||
|
@ -3,6 +3,7 @@ package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||
public enum RTP_TYPE {
|
||||
COMMAND, //Player executed command
|
||||
FORCED, //Player was forced to rtp (/rtp player <player>)
|
||||
RESPAWN, //Player respawned and world has RTPOnDeath enabled
|
||||
JOIN, //Player joined and was rtp'd automatically
|
||||
TEST, //Player was just testing out effects
|
||||
ADDON, //Player RTP'd from the external addons plugin
|
||||
|
@ -39,4 +39,6 @@ public interface RTPWorld {
|
||||
}
|
||||
|
||||
long getCooldown();
|
||||
|
||||
boolean getRTPOnDeath();
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ public interface RTPWorld_Defaulted {
|
||||
|
||||
void setCooldown(long value);
|
||||
|
||||
void setRTPOnDeath(boolean bool);
|
||||
|
||||
default void setupDefaults() {
|
||||
setAllFrom(BetterRTP.getInstance().getRTP().getRTPdefaultWorld());
|
||||
}
|
||||
@ -48,5 +50,6 @@ public interface RTPWorld_Defaulted {
|
||||
setMinY(rtpWorld.getMinY());
|
||||
setMaxY(rtpWorld.getMaxY());
|
||||
setCooldown(rtpWorld.getCooldown());
|
||||
setRTPOnDeath(rtpWorld.getRTPOnDeath());
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.util.Map;
|
||||
|
||||
public class WorldCustom implements RTPWorld, RTPWorld_Defaulted {
|
||||
public World world;
|
||||
private boolean useWorldborder;
|
||||
private boolean useWorldborder, RTPOnDeath;
|
||||
private int centerX, centerZ, maxRad, minRad, price, miny, maxy;
|
||||
private long cooldown;
|
||||
private List<String> biomes;
|
||||
@ -202,6 +202,10 @@ public class WorldCustom implements RTPWorld, RTPWorld_Defaulted {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
@Override public boolean getRTPOnDeath() {
|
||||
return RTPOnDeath;
|
||||
}
|
||||
|
||||
//Setters
|
||||
@Override
|
||||
public void setUseWorldBorder(boolean value) {
|
||||
@ -262,4 +266,8 @@ public class WorldCustom implements RTPWorld, RTPWorld_Defaulted {
|
||||
public void setCooldown(long value) {
|
||||
this.cooldown = value;
|
||||
}
|
||||
|
||||
@Override public void setRTPOnDeath(boolean bool) {
|
||||
RTPOnDeath = bool;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class WorldDefault implements RTPWorld {
|
||||
private boolean useWorldborder;
|
||||
private boolean useWorldborder, RTPOnDeath;
|
||||
private int centerX, centerZ, maxRad, minRad, price, miny, maxy;
|
||||
private List<String> Biomes;
|
||||
private final HashMap<String, Integer> prices = new HashMap<>();
|
||||
@ -26,6 +26,7 @@ public class WorldDefault implements RTPWorld {
|
||||
FileOther.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.CONFIG);
|
||||
//Booleans
|
||||
useWorldborder = config.getBoolean(pre + ".UseWorldBorder");
|
||||
RTPOnDeath = config.getBoolean(pre + ".RTPOnDeath");
|
||||
//Integers
|
||||
centerX = config.getInt(pre + ".CenterX");
|
||||
centerZ = config.getInt(pre + ".CenterZ");
|
||||
@ -149,4 +150,8 @@ public class WorldDefault implements RTPWorld {
|
||||
public long getCooldown() {
|
||||
return BetterRTP.getInstance().getCooldowns().getDefaultCooldownTime();
|
||||
}
|
||||
|
||||
@Override public boolean getRTPOnDeath() {
|
||||
return RTPOnDeath;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WorldLocation implements RTPWorld, RTPWorld_Defaulted {
|
||||
private boolean useWorldborder;
|
||||
private boolean useWorldborder, RTPOnDeath;
|
||||
private int centerX, centerZ, maxRad, minRad, price, miny, maxy;
|
||||
private long cooldown;
|
||||
private List<String> biomes;
|
||||
@ -143,6 +143,12 @@ public class WorldLocation implements RTPWorld, RTPWorld_Defaulted {
|
||||
this.cooldown = Long.parseLong(section.get("Cooldown").toString());
|
||||
BetterRTP.debug("- - Cooldown: " + cooldown);
|
||||
}
|
||||
if (section.get("RTPOnDeath") != null) {
|
||||
if (section.get("RTPOnDeath").getClass() == Boolean.class) {
|
||||
RTPOnDeath = Boolean.parseBoolean(section.get("RTPOnDeath").toString());
|
||||
BetterRTP.debug("- - RTPOnDeath: " + RTPOnDeath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -217,6 +223,10 @@ public class WorldLocation implements RTPWorld, RTPWorld_Defaulted {
|
||||
public long getCooldown() {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
@Override public boolean getRTPOnDeath() {
|
||||
return RTPOnDeath;
|
||||
}
|
||||
//Setters
|
||||
|
||||
@Override
|
||||
@ -278,4 +288,8 @@ public class WorldLocation implements RTPWorld, RTPWorld_Defaulted {
|
||||
public void setCooldown(long value) {
|
||||
this.cooldown = value;
|
||||
}
|
||||
|
||||
@Override public void setRTPOnDeath(boolean bool) {
|
||||
this.RTPOnDeath = bool;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.util.*;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class WorldPermissionGroup implements RTPWorld, RTPWorld_Defaulted {
|
||||
private boolean useWorldborder;
|
||||
private boolean useWorldborder, RTPOnDeath;
|
||||
private int centerX, centerZ, maxRad, minRad, price, miny, maxy;
|
||||
private List<String> biomes;
|
||||
public World world;
|
||||
@ -123,6 +123,12 @@ public class WorldPermissionGroup implements RTPWorld, RTPWorld_Defaulted {
|
||||
this.cooldown = Long.parseLong(hash3.getValue().toString());
|
||||
BetterRTP.debug("- - Cooldown: " + cooldown);
|
||||
}
|
||||
if (field.equalsIgnoreCase("RTPOnDeath")) {
|
||||
if (hash3.getValue().getClass() == Boolean.class) {
|
||||
RTPOnDeath = Boolean.parseBoolean(hash3.getValue().toString());
|
||||
BetterRTP.debug("- - RTPOnDeath: " + RTPOnDeath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,6 +192,10 @@ public class WorldPermissionGroup implements RTPWorld, RTPWorld_Defaulted {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
@Override public boolean getRTPOnDeath() {
|
||||
return RTPOnDeath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseWorldBorder(boolean value) {
|
||||
this.useWorldborder = value;
|
||||
@ -246,78 +256,7 @@ public class WorldPermissionGroup implements RTPWorld, RTPWorld_Defaulted {
|
||||
this.cooldown = value;
|
||||
}
|
||||
|
||||
/*public static class RTPPermConfiguration {
|
||||
|
||||
boolean valid;
|
||||
public String name;
|
||||
public List<RTPPermConfigurationWorld> worlds = new ArrayList<>();
|
||||
|
||||
RTPPermConfiguration(Map.Entry<?, ?> fields) {
|
||||
String group = fields.getKey().toString();
|
||||
Object value = fields.getValue();
|
||||
for (Object worlds : ((ArrayList) value)) {
|
||||
for (Object hash : ((HashMap) worlds).entrySet()) {
|
||||
RTPPermConfigurationWorld worldConfig = new RTPPermConfigurationWorld(hash, group);
|
||||
if (worldConfig.isValid())
|
||||
this.worlds.add(worldConfig);
|
||||
else
|
||||
BetterRTP.debug("ERROR! Group " + group + " world " + worldConfig.name + " was not setup correctly!");
|
||||
}
|
||||
}
|
||||
this.name = group;
|
||||
valid = worlds.size() > 0 && group != null;
|
||||
}
|
||||
|
||||
boolean isValid() {
|
||||
return valid;
|
||||
}
|
||||
@Override public void setRTPOnDeath(boolean bool) {
|
||||
this.RTPOnDeath = bool;
|
||||
}
|
||||
|
||||
public static class RTPPermConfigurationWorld {
|
||||
|
||||
boolean valid;
|
||||
|
||||
public int maxRad = -1;
|
||||
public int minRad = -1;
|
||||
public int price = -1;
|
||||
public int centerx = -1;
|
||||
public int centerz = -1;
|
||||
public Object useworldborder = null;
|
||||
|
||||
public String name;
|
||||
|
||||
RTPPermConfigurationWorld(Object hash, String group) {
|
||||
Map.Entry world = (Map.Entry) hash;
|
||||
this.name = world.getKey().toString();
|
||||
//Main.getInstance().getLogger().info("World added to '" + group +"': '" + world.getKey() + "'");
|
||||
for (Object hash2 : ((HashMap) world.getValue()).entrySet()) {
|
||||
Map.Entry hash3 = (Map.Entry) hash2;
|
||||
String field = hash3.getKey().toString();
|
||||
if (field.equalsIgnoreCase("MaxRadius")) { //MaxRadius
|
||||
maxRad = getInt(hash3.getValue().toString());
|
||||
} else if (field.equalsIgnoreCase("MinRadius")) { //MinRadius
|
||||
minRad = getInt(hash3.getValue().toString());
|
||||
} else if (field.equalsIgnoreCase("Price")) { //MinRadius
|
||||
price = getInt(hash3.getValue().toString());
|
||||
} else if (field.equalsIgnoreCase("UseWorldBorder")) { //UseWorldBorder
|
||||
useworldborder = Boolean.valueOf(hash3.getValue().toString());
|
||||
} else if (field.equalsIgnoreCase("CenterX")) { //Center X
|
||||
centerx = getInt(hash3.getValue().toString());
|
||||
} else if (field.equalsIgnoreCase("CenterZ")) { //Center Z
|
||||
centerz = getInt(hash3.getValue().toString());
|
||||
}
|
||||
}
|
||||
//Main.getInstance().getLogger().info("World MaxRad '" + world.getKey() + "' is " + maxRad);
|
||||
//Main.getInstance().getLogger().info("World MinRad '" + world.getKey() + "' is " + minRad);
|
||||
valid = this.name != null && (minRad != -1 || maxRad != -1);
|
||||
}
|
||||
|
||||
private int getInt(String input) {
|
||||
return Integer.parseInt(input);
|
||||
}
|
||||
|
||||
boolean isValid() {
|
||||
return valid;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import java.util.*;
|
||||
|
||||
public class WorldPlayer implements RTPWorld, RTPWorld_Defaulted {
|
||||
private boolean useWorldborder;
|
||||
private boolean RTPOnDeath;
|
||||
private int CenterX, CenterZ, maxRad, minRad, price, min_y, max_y;
|
||||
private long cooldown;
|
||||
private List<String> Biomes;
|
||||
@ -51,6 +52,7 @@ public class WorldPlayer implements RTPWorld, RTPWorld_Defaulted {
|
||||
setup_type = RTP_SETUP_TYPE.PERMISSIONGROUP;
|
||||
this.setup_name = setup_name;
|
||||
setUseWorldBorder(world.getUseWorldborder());
|
||||
setRTPOnDeath(world.getRTPOnDeath());
|
||||
|
||||
//BetterRTP.getInstance().getLogger().info("WorldPlayer Center x: " + CenterX);
|
||||
setCenterX(world.getCenterX());
|
||||
@ -164,6 +166,10 @@ public class WorldPlayer implements RTPWorld, RTPWorld_Defaulted {
|
||||
useWorldborder = bool;
|
||||
}
|
||||
|
||||
@Override public void setRTPOnDeath(boolean bool) {
|
||||
RTPOnDeath = bool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCenterX(int x) {
|
||||
CenterX = x;
|
||||
@ -240,4 +246,9 @@ public class WorldPlayer implements RTPWorld, RTPWorld_Defaulted {
|
||||
public long getCooldown() {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
@Override public boolean getRTPOnDeath() {
|
||||
return RTPOnDeath;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,134 +0,0 @@
|
||||
# BetterRTP plugin by SuperRonanCraft! (Join my Public Server mc.RonanCraft.net) #
|
||||
# Need help? go to https://ronancraft.net/discord! #
|
||||
|
||||
Language-File: 'en.yml'
|
||||
|
||||
Settings:
|
||||
Respect:
|
||||
## Respect WorldGuard areas (https://dev.bukkit.org/projects/worldguard)
|
||||
WorldGuard: false
|
||||
## Respect GriefPrevention areas (https://www.spigotmc.org/resources/griefprevention.1884/)
|
||||
GriefPrevention: false
|
||||
## Respect Towny areas (https://www.spigotmc.org/resources/towny.72694/)
|
||||
Towny: false
|
||||
## Respect RedProtect areas (https://www.spigotmc.org/resources/redprotect.15841/)
|
||||
RedProtect: false
|
||||
## Respect FactionsUUID areas (https://www.spigotmc.org/resources/factionsuuid.1035/)
|
||||
FactionsUUID: false
|
||||
## Respect Lands areas (https://www.spigotmc.org/resources/lands.53313/)
|
||||
Lands: false
|
||||
## Respect Residence areas (https://www.spigotmc.org/resources/residence.11480/)
|
||||
Residence: false
|
||||
## Respect KingdomsX areas (https://www.spigotmc.org/resources/kingdomsx.77670/)
|
||||
KingdomsX: false
|
||||
## Output to console some debugging info
|
||||
Debugger: false
|
||||
## Amount of chunks to preload around a safe location
|
||||
PreloadRadius: 5
|
||||
## Maximum amount of tries before BetterRTP gives up and sends a NotSafeMessage #
|
||||
MaxAttempts: 32
|
||||
RtpOnFirstJoin: # Will execute as console to override delays
|
||||
Enabled: false # Make the player rtp when joining the server for the first time
|
||||
World: 'world' # World to first rtp in
|
||||
SetAsRespawn: false # Save this first rtp as players new spawn point
|
||||
Cooldown:
|
||||
Enabled: true # Enabled or disabled cooldown timer
|
||||
LockAfter: 0 # Lock the player in an infinite cooldown after # rtp's (0 to disable)
|
||||
Time: 600 # in SECONDS
|
||||
## Time between command and actually rtp'ing, time is in SECONDS. Set to "0" to disable delay timer #
|
||||
Delay:
|
||||
Enabled: true
|
||||
Time: 5
|
||||
CancelOnMove: true
|
||||
StatusMessages: true # Send extra information about current status of RTP
|
||||
DisableUpdater: false
|
||||
|
||||
Default:
|
||||
UseWorldBorder: false
|
||||
## "Biomes: []" means all biomes are allowed! #
|
||||
## Biomes are optional, more biomes at https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Biome.html #
|
||||
Biomes: []
|
||||
MaxRadius: 1000
|
||||
MinRadius: 10
|
||||
## If "UseWorldBorder" is set to true above, Center X and Z will be ignored! #
|
||||
CenterX: 0
|
||||
CenterZ: 0
|
||||
Shape: 'square'
|
||||
|
||||
## Blocks BetterRTP will NOT teleport onto. More Blocks at: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html #
|
||||
BlacklistedBlocks:
|
||||
- stationary_water
|
||||
- stationary_lava
|
||||
- water
|
||||
- flowing_water
|
||||
- lava
|
||||
- flowing_lava
|
||||
- cactus
|
||||
- leaves
|
||||
- leaves_2
|
||||
- air
|
||||
- void_air
|
||||
- bedrock
|
||||
- oak_leaves
|
||||
- jungle_leaves
|
||||
|
||||
## Worlds to NOT allow /rtp in, unless there is an override to another enabled world #
|
||||
DisabledWorlds:
|
||||
- prison
|
||||
- creative
|
||||
|
||||
## Worlds you want to have a custom min/max and spawn center in #
|
||||
## [MaxRadius] and [MinRadius] MUST be positive! These cannot be equal to each other!
|
||||
CustomWorlds:
|
||||
- custom_world_1:
|
||||
UseWorldBorder: false
|
||||
## If UseWorldBorder is true, everything will be ignored EXCEPT "MinRadius"!
|
||||
MaxRadius: 1000
|
||||
MinRadius: 100
|
||||
CenterX: 0
|
||||
CenterZ: 0
|
||||
Price: 50
|
||||
Shape: 'square'
|
||||
- other_custom_world:
|
||||
MaxRadius: 10000
|
||||
MinRadius: 150
|
||||
CenterX: 123
|
||||
CenterZ: -123
|
||||
Price: 0
|
||||
## Biomes are optional, but useful! More biomes: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Biome.html
|
||||
Biomes:
|
||||
- 'desert'
|
||||
- 'forest'
|
||||
Shape: 'circle'
|
||||
|
||||
## Override a world and rtp a player executing the command in one world, to another
|
||||
Overrides:
|
||||
#FORMAT - <CURRENT WORLD>:<DESIRED WORLD>
|
||||
- master_world: 'world'
|
||||
- creative_world: 'world'
|
||||
|
||||
WorldType: # Available types are NORMAL, NETHER
|
||||
- world: NORMAL
|
||||
- world_nether: NETHER
|
||||
- world_the_end: NORMAL
|
||||
|
||||
PermissionGroup: #Player requires "betterrtp.group.<world_name>" to trigger these configs
|
||||
Enabled: false
|
||||
Groups:
|
||||
- vip: # permission: betterrtp.config.vip
|
||||
- Build_World: #World named "Build_World"
|
||||
MaxRadius: 10000
|
||||
MinRadius: 1000
|
||||
Price: 100
|
||||
- Survival_World:
|
||||
UseWorldBorder: false
|
||||
MaxRadius: 5000
|
||||
MinRadius: 1000
|
||||
CenterX: 10
|
||||
CenterZ: 10
|
||||
Price: 10
|
||||
- vip2: # permission: betterrtp.config.vip2
|
||||
- Build_World:
|
||||
MaxRadius: 25000
|
||||
MinRadius: 10000
|
||||
Price: 15
|
@ -81,6 +81,7 @@ Default:
|
||||
Shape: 'square'
|
||||
MaxY: 320
|
||||
MinY: 0
|
||||
RTPOnDeath: false
|
||||
|
||||
## Blocks BetterRTP will NOT teleport onto. More Blocks at: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html #
|
||||
BlacklistedBlocks:
|
||||
@ -131,6 +132,7 @@ CustomWorlds:
|
||||
- 'desert'
|
||||
- 'forest'
|
||||
Shape: 'circle'
|
||||
RTPOnDeath: true
|
||||
|
||||
## Override a world and rtp a player executing the command in one world, to another
|
||||
Overrides:
|
||||
|
Loading…
x
Reference in New Issue
Block a user