3.0.4 release - RTP shapes

This commit is contained in:
SuperRonanCraft 2021-01-14 00:22:20 -05:00
parent 563baee57e
commit c0846e5413
7 changed files with 50 additions and 4 deletions

View File

@ -137,6 +137,7 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
info.add("&7- &6Price: &f" + _rtpworld.getPrice() + getInfo(_rtpworld, worldDefault, "price"));
info.add("&7- &6World Type: &f" + _rtpworld.getWorldtype().name());
info.add("&7- &6Biomes: &f" + _rtpworld.getBiomes().toString());
info.add("&7- &6Shape: &f" + _rtpworld.getShape().toString());
}
}
return info;

View File

@ -2,5 +2,5 @@ package me.SuperRonanCraft.BetterRTP.player.rtp;
public enum RTP_SHAPE {
SQUARE, //Square shaped location finder
ROUND //Circled area location finder
CIRCLE //Circled area location finder
}

View File

@ -1,5 +1,6 @@
package me.SuperRonanCraft.BetterRTP.references.worlds;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_SHAPE;
import org.bukkit.World;
import java.util.List;
@ -21,4 +22,6 @@ public interface RTPWorld {
List<String> getBiomes();
World getWorld();
RTP_SHAPE getShape();
}

View File

@ -1,5 +1,6 @@
package me.SuperRonanCraft.BetterRTP.references.worlds;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_SHAPE;
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
import me.SuperRonanCraft.BetterRTP.BetterRTP;
import org.bukkit.Bukkit;
@ -14,6 +15,7 @@ public class WorldCustom implements RTPWorld {
private boolean useWorldborder;
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price;
private List<String> Biomes;
private RTP_SHAPE shape;
public WorldCustom(String world) {
//String pre = "CustomWorlds.";
@ -30,6 +32,7 @@ public class WorldCustom implements RTPWorld {
CenterZ = worldDefault.getCenterZ();
price = worldDefault.getPrice();
Biomes = worldDefault.getBiomes();
shape = worldDefault.getShape();
//Find Custom World and cache values
for (Map<?, ?> m : map) {
@ -85,6 +88,15 @@ public class WorldCustom implements RTPWorld {
price = worldDefault.getPrice(world);
} else
price = worldDefault.getPrice(world);
if (test.get("Shape") != null) {
if (test.get("Shape").getClass() == String.class) {
try {
this.shape = RTP_SHAPE.valueOf(test.get("Shape").toString().toUpperCase());
} catch (Exception e) {
//Invalid shape
}
}
}
}
}
//Booleans
@ -161,4 +173,9 @@ public class WorldCustom implements RTPWorld {
public World getWorld() {
return Bukkit.getWorld(world);
}
@Override
public RTP_SHAPE getShape() {
return shape;
}
}

View File

@ -1,6 +1,7 @@
package me.SuperRonanCraft.BetterRTP.references.worlds;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_SHAPE;
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
import me.SuperRonanCraft.BetterRTP.BetterRTP;
import org.bukkit.Bukkit;
@ -16,6 +17,7 @@ public class WorldDefault implements RTPWorld {
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price;
private List<String> Biomes;
private final HashMap<String, Integer> prices = new HashMap<>();
private RTP_SHAPE shape;
public void setup() {
//Setups
@ -27,6 +29,11 @@ public class WorldDefault implements RTPWorld {
CenterX = config.getInt(pre + ".CenterX");
CenterZ = config.getInt(pre + ".CenterZ");
maxBorderRad = config.getInt(pre + ".MaxRadius");
try {
shape = RTP_SHAPE.valueOf(config.getString(pre + ".Shape").toUpperCase());
} catch (Exception e) {
shape = RTP_SHAPE.SQUARE;
}
if (maxBorderRad <= 0) {
BetterRTP.getInstance().getText().sms(Bukkit.getConsoleSender(),
"WARNING! Default Maximum radius of '" + maxBorderRad + "' is not allowed! Set to '1000'");
@ -100,4 +107,9 @@ public class WorldDefault implements RTPWorld {
public World getWorld() {
return null;
}
@Override
public RTP_SHAPE getShape() {
return shape;
}
}

View File

@ -21,7 +21,7 @@ public class WorldPlayer implements RTPWorld {
private final World world;
private WORLD_TYPE world_type;
private RTPPermissionGroup.RTPPermConfiguration config = null;
private RTP_SHAPE shape = RTP_SHAPE.SQUARE;
private RTP_SHAPE shape;
//Economy
public boolean eco_money_taken = false;
@ -36,6 +36,7 @@ public class WorldPlayer implements RTPWorld {
setCenterZ(world.getCenterZ());
setMaxRad(world.getMaxRad());
setMinRad(world.getMinRad());
setShape(world.getShape());
if (world instanceof WorldDefault)
setPrice(((WorldDefault) world).getPrice(getWorld().getName()));
else
@ -114,8 +115,8 @@ public class WorldPlayer implements RTPWorld {
public Location generateLocation() {
Location loc = null;
switch (shape) {
//case ROUND: //DISABLED UNTIL NEXT PATCH
// loc = generateRound(getMaxRad(), getMinRad()); break;
case CIRCLE: //DISABLED UNTIL NEXT PATCH
loc = generateRound(getMaxRad(), getMinRad()); break;
default:
loc = generateSquare(getMaxRad(), getMinRad()); break;
}
@ -204,6 +205,11 @@ public class WorldPlayer implements RTPWorld {
return Biomes;
}
@Override
public RTP_SHAPE getShape() {
return shape;
}
private void setUseWorldborder(boolean bool) {
useWorldborder = bool;
}
@ -243,6 +249,10 @@ public class WorldPlayer implements RTPWorld {
this.world_type = type;
}
public void setShape(RTP_SHAPE shape) {
this.shape = shape;
}
public RTPPermissionGroup.RTPPermConfiguration getConfig() {
return this.config;
}

View File

@ -52,6 +52,7 @@ Default:
## 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:
@ -86,6 +87,7 @@ CustomWorlds:
CenterX: 0
CenterZ: 0
Price: 50
Shape: 'square'
- other_custom_world:
MaxRadius: 10000
MinRadius: 150
@ -96,6 +98,7 @@ CustomWorlds:
Biomes:
- 'desert'
- 'forest'
Shape: 'circle'
## Override a world and rtp a player executing the command in one world, to another
Overrides: