Skip to content

Commit

Permalink
Updated to MC1.15.2-3.1.1
Browse files Browse the repository at this point in the history
This version adds just one/two features and solve some minor issues. Here is a detailed change-log:
- Added max tries to the /rtp command
- Fixed minor issues

How to update:
1. Delete the old .jar file from the mods folder of the server root
2. Move the new .jar to the folder mods of the server root
  • Loading branch information
Picono435 authored Aug 22, 2020
1 parent 1b08832 commit d433ae5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 28 deletions.
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = 'MC1.15.2-3.1'
version = 'MC1.15.2-3.1.1'
group = 'com.gmail.picono435.randomtp' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'RandomTP'

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
//Print out JVM information so that we know what version is running. Extreamly useful for people to know when helping you.
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))

minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'snapshot', version: '20200514-1.15.1'
mappings channel: 'snapshot', version: '20200806-1.15.1'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
Expand Down Expand Up @@ -89,7 +91,7 @@ dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.15.2-31.2.30'
minecraft 'net.minecraftforge:forge:1.15.2-31.2.36'

// You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier"
Expand Down Expand Up @@ -143,4 +145,4 @@ publishing {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private static void randomTeleport(PlayerEntity p) {
int x = r.nextInt(high-low) + low;
int y = 50;
int z = r.nextInt(high-low) + low;
int maxTries = -1;
int maxTries = Config.maxTries.get();
while (!isSafe(p, x, y, z) && (maxTries == -1 || maxTries > 0)) {
y++;
if(y >= 120) {
Expand All @@ -131,7 +131,7 @@ private static void randomTeleport(PlayerEntity p) {
}

p.setPositionAndUpdate(x, y, z);
StringTextComponent succefull = new StringTextComponent(Messages.succefully.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockZ\\}", "" + p.getPositionVector().z).replaceAll("\\{blockX\\}", "" + p.getPositionVector().x).replaceAll("&", "§"));
StringTextComponent succefull = new StringTextComponent(Messages.succefully.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockZ\\}", "" + p.getPositionVec().z).replaceAll("\\{blockX\\}", "" + p.getPositionVec().x).replaceAll("&", "§"));
p.sendMessage(succefull);
} catch(Exception ex) {
MainMod.logger.info("Error executing command.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ private static int runCommand(PlayerEntity p, DimensionType dim) {
double cal = border.getDiameter()/2;
BigDecimal num = new BigDecimal(cal);
String maxDistance = num.toPlainString();
int dimensionId = dim.getId();
String dimensionId = dim.getRegistryName().toString();
p.setPortal(p.getPosition());
if(!inWhitelist(dimensionId)) {
p.sendMessage(new StringTextComponent(Messages.dimensionNotAllowed.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{dimensionId\\}", dim.getId() + "").replace('&', '§')));
p.sendMessage(new StringTextComponent(Messages.dimensionNotAllowed.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{dimensionId\\}", dimensionId + "").replace('&', '§')));
return 1;
}
p.changeDimension(dim);
Expand All @@ -80,11 +80,6 @@ private static int runCommand(PlayerEntity p, DimensionType dim) {
cooldowns.put(p.getName().getString(), System.currentTimeMillis());
return 1;
}
if(Config.useOriginal.get()) {
randomTeleport(p);
cooldowns.put(p.getName().getString(), System.currentTimeMillis());
return 1;
}
if(Config.max_distance.get() == 0) {
server.getCommandManager().handleCommand(server.getCommandSource(), "spreadplayers " + border.getCenterX() + " " + border.getCenterZ() + " " + Config.min_distance.get() + " " + maxDistance + " false " + p.getName().getString().toLowerCase());
p.sendMessage(succefull);
Expand Down Expand Up @@ -118,13 +113,13 @@ private static long getCooldownLeft(PlayerEntity p) {
return secondsLeft;
}

public static boolean inWhitelist(int dimension) {
public static boolean inWhitelist(String dimension) {
//WHITELIST
if(Config.useWhitelist.get()) {
return Config.allowedDimensions.get().contains(dimension + "");
return Config.allowedDimensions.get().contains(dimension);
//BLACKLIST
} else {
return !Config.allowedDimensions.get().contains(dimension + "");
return !Config.allowedDimensions.get().contains(dimension);
}
}

Expand All @@ -137,7 +132,7 @@ private static boolean hasPermission(CommandSource source) {
}

private static void randomTeleport(PlayerEntity p) {
try {
try {
Random r = new Random();
int low = Config.min_distance.get();
int high = Config.max_distance.get();
Expand All @@ -147,7 +142,7 @@ private static void randomTeleport(PlayerEntity p) {
int x = r.nextInt(high-low) + low;
int y = 50;
int z = r.nextInt(high-low) + low;
int maxTries = -1;
int maxTries = Config.maxTries.get();
while (!isSafe(p, x, y, z) && (maxTries == -1 || maxTries > 0)) {
y++;
if(y >= 120) {
Expand All @@ -167,7 +162,7 @@ private static void randomTeleport(PlayerEntity p) {
}

p.setPositionAndUpdate(x, y, z);
StringTextComponent succefull = new StringTextComponent(Messages.succefully.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockZ\\}", "" + p.getPositionVector().z).replaceAll("\\{blockX\\}", "" + p.getPositionVector().x).replaceAll("&", "§"));
StringTextComponent succefull = new StringTextComponent(Messages.succefully.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockZ\\}", "" + p.getPositionVec().z).replaceAll("\\{blockX\\}", "" + p.getPositionVec().x).replaceAll("&", "§"));
p.sendMessage(succefull);
} catch(Exception ex) {
MainMod.logger.info("Error executing command.");
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/com/gmail/picono435/randomtp/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Config {

public static ForgeConfigSpec.ConfigValue<Integer> cooldown;
public static ForgeConfigSpec.ConfigValue<Boolean> useOriginal;
public static ForgeConfigSpec.ConfigValue<Integer> maxTries;

public static ForgeConfigSpec.ConfigValue<Boolean> dim;
public static ForgeConfigSpec.ConfigValue<Boolean> useWhitelist;
Expand All @@ -38,22 +39,26 @@ public static void initConfig(ForgeConfigSpec.Builder config) {
.define("inter-dimensions-command.inter-dim", true);

useWhitelist = config
.comment("Do you want to use the whitelist or blacklist dimension? [default: true]")
.define("inter-dimensions-command.use-whitelist", true);
.comment("Do you want to use the whitelist or blacklist dimension? [default: false]")
.define("inter-dimensions-command.use-whitelist", false);

String[] array = {"1", "-1"};
String[] array = {"minecraft:the_end", "twilight:dimension"};
allowedDimensions = config
.comment("The dimensions whitelist (Works with IDs only, use-whitelist:true=whitelist use-whitelist:true=blacklist) [default: [1], [2]]")
.define("inter-dimensions.allowed-dimensions", Arrays.asList(array));
.comment("The dimensions whitelist (Works with namespaces:paths only, use-whitelist:true=whitelist use-whitelist:true=blacklist) [default: [minecraft:the_end], [twilight:dimension]]")
.define("inter-dimensions-command.whitelist-dimension", Arrays.asList(array));

//OTHERS CATEGORY
cooldown = config
.comment("How much cooldown do you want for the command (put 0 for none) [range: 0 ~ 1000, default: 0]")
.defineInRange("others.cooldown", 0, 0, Integer.MAX_VALUE);

useOriginal = config
.comment("If you want to use the original RTP system or the /spreadplayers system. *ORIGINAL SYSTEM STILL ON BETA*")
.define("others.use-original", false);
.comment("If you want to use the original RTP system or the /spreadplayers system.")
.define("others.use-original", true);

maxTries = config
.comment("The amount of tries to find a safe location (original system) [-1 = infinite]")
.define("others.max-tries", -1);

//PERMISSION CATEGORY
only_op_basic = config
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
modLoader="javafml" #mandatory
loaderVersion="[28,)" #mandatory (28 is current forge version)
issueTrackerURL="https://github.com/Picono435/RandomTP/issues" #optional
license="GNU GENERAL PUBLIC LICENSE v3"
[[mods]] #mandatory
modId="randomtp" #mandatory
version="MC1.15.2-3.1" #mandatory
version="MC1.15.2-3.1.1" #mandatory
displayName="Random Teleport Mod" #mandatory
displayURL="https://www.piconodev.tk/" #optional
logoFile="logo.jpeg" #optional
credits="Thanks to everyone that helped me and PiconoDev growing." #optional
authors="Picono435" #optional
description='''
A mod that teleports you to a random location without colliding with lava, water or the world border.
'''
'''

0 comments on commit d433ae5

Please sign in to comment.