Skip to content

Commit

Permalink
MC1.16-4.1.3 (Forge 1.16.x)
Browse files Browse the repository at this point in the history
This version just moves RandomTP mod from 1.16.3 to 1.16.4, so with this version you can run both (1.16.1, 1.16.2, 1.16.3 & 1.16.4) Here is a detailed change-log:
- Added support to 1.16.4
- Added new max tries message
- Added new permission (randomtp.cooldown.exempt) to ignore cooldown [DEFAULT: OP]
- Added {blockZ} placeholder
- Changed the default messages
- Fixed issues with placeholders
- Fixed issue with max tries
- Fixed minor issues
- Removed only_op options (Now permissions are fully controlled by nodes)

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

Permissions:
randomtp.command.basic - Execute /randomtp [DEFAULT: ALL]
randomtp.command.interdim - Execute /randomtpdimension [DEFAULT: ALL]
randomtp.cooldown.exempt - Ignore cooldown [DEFAULT: OP]
  • Loading branch information
Picono435 authored Dec 23, 2020
1 parent d16c664 commit 25036d7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 41 deletions.
20 changes: 12 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

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

Expand All @@ -26,7 +26,7 @@ minecraft {
// 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: '20200723-1.16.1'
mappings channel: 'snapshot', version: '20201028-1.16.3'
// 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 @@ -75,7 +75,8 @@ minecraft {
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'

args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', 'randomtp', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')

mods {
examplemod {
Expand All @@ -86,11 +87,14 @@ minecraft {
}
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }

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.16.2-33.0.5'
minecraft 'net.minecraftforge:forge:1.16.4-35.1.0'

// 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 All @@ -116,12 +120,12 @@ dependencies {
jar {
manifest {
attributes([
"Specification-Title": "examplemod",
"Specification-Vendor": "examplemodsareus",
"Specification-Version": "1", // We are version 1 of ourselves
"Specification-Title": "randomtp",
"Specification-Vendor": "randomtpmod",
"Specification-Version": project.version, // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"examplemodsareus",
"Implementation-Vendor" :"randomtpmod",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
Expand Down
13 changes: 4 additions & 9 deletions src/main/java/com/gmail/picono435/randomtp/MainMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@

@Mod("randomtp")
public class MainMod {

public static final String MODID = "randomtp";
public static final String NAME = "Random Teleport Mod";
public static final String VERSION = "1.3";
public static String minecraftVersion = "";


public static final String NEW_LINE;

public static Logger logger;
Expand Down Expand Up @@ -62,14 +57,14 @@ public void preInit(FMLCommonSetupEvent event) {

@SubscribeEvent
public void init(FMLServerStartingEvent event) {
minecraftVersion = event.getServer().getMinecraftVersion();
logger.info("Initalized Random Teleport Mod.");
server = event.getServer();

logger.info("Configs files loaded.");

PermissionAPI.registerNode("randomtp.command.basic", DefaultPermissionLevel.OP, "The permission to execute the command /randomtp");
PermissionAPI.registerNode("randomtp.command.interdim", DefaultPermissionLevel.OP, "The permission to execute the command /randomtp");
PermissionAPI.registerNode("randomtp.command.basic", DefaultPermissionLevel.ALL, "The permission to execute the command /randomtp");
PermissionAPI.registerNode("randomtp.command.interdim", DefaultPermissionLevel.ALL, "The permission to execute the command /randomtpdimension");
PermissionAPI.registerNode("randomtp.cooldown.exempt", DefaultPermissionLevel.OP, "The permission used to be exempt from the cooldown");
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ private static int runCommand(PlayerEntity p) {
World world = p.getEntityWorld();
WorldBorder border = world.getWorldBorder();
MinecraftServer server = MainMod.server;
StringTextComponent succefull = new StringTextComponent(Messages.succefully.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockZ\\}", "" + p.getPositionVec().z).replaceAll("\\{blockX\\}", "" + p.getPositionVec().x).replaceAll("&", "§"));
if(!checkCooldown(p)) {
if(!checkCooldown(p) && !PermissionAPI.hasPermission(p, "randomtp.cooldown.exempt")) {
long secondsLeft = getCooldownLeft(p);
StringTextComponent cooldownmes = new StringTextComponent(Messages.cooldown.get().replaceAll("\\{secondsLeft\\}", Long.toString(secondsLeft)).replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("&", "§"));
p.sendMessage(cooldownmes, p.getUniqueID());
Expand All @@ -61,9 +60,11 @@ private static int runCommand(PlayerEntity p) {
String maxDistance = num.toPlainString();
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());
StringTextComponent succefull = new StringTextComponent(Messages.succefully.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockX\\}", "" + (int)p.getPositionVec().x).replaceAll("\\{blockY\\}", "" + (int)p.getPositionVec().y).replaceAll("\\{blockZ\\}", "" + (int)p.getPositionVec().z).replaceAll("&", "§"));
p.sendMessage(succefull, p.getUniqueID());
} else {
server.getCommandManager().handleCommand(server.getCommandSource(), "spreadplayers " + border.getCenterX() + " " + border.getCenterZ() + " " + Config.min_distance.get() + " " + Config.max_distance.get() + " false " + p.getName().getString().toLowerCase());
StringTextComponent succefull = new StringTextComponent(Messages.succefully.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockX\\}", "" + (int)p.getPositionVec().x).replaceAll("\\{blockY\\}", "" + (int)p.getPositionVec().y).replaceAll("\\{blockZ\\}", "" + (int)p.getPositionVec().z).replaceAll("&", "§"));
p.sendMessage(succefull, p.getUniqueID());
}
cooldowns.put(p.getName().getString(), System.currentTimeMillis());
Expand Down Expand Up @@ -124,14 +125,14 @@ private static void randomTeleport(PlayerEntity p) {
maxTries--;
}
if(maxTries == 0) {
StringTextComponent msg = new StringTextComponent("Error, please try again.");
StringTextComponent msg = new StringTextComponent(Messages.maxTries.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("&", "§"));
p.sendMessage(msg, p.getUniqueID());
return;
}
}

p.setPositionAndUpdate(x, y, z);
StringTextComponent succefull = new StringTextComponent(Messages.succefully.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockZ\\}", "" + p.getPositionVec().z).replaceAll("\\{blockX\\}", "" + p.getPositionVec().x).replaceAll("&", "§"));
StringTextComponent succefull = new StringTextComponent(Messages.succefully.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockX\\}", "" + (int)p.getPositionVec().x).replaceAll("\\{blockY\\}", "" + (int)p.getPositionVec().y).replaceAll("\\{blockZ\\}", "" + (int)p.getPositionVec().z).replaceAll("&", "§"));
p.sendMessage(succefull, p.getUniqueID());
} catch(Exception ex) {
MainMod.logger.info("Error executing command.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ private static int runCommand(PlayerEntity p, ServerWorld dim) {
World world = p.getEntityWorld();
WorldBorder border = world.getWorldBorder();
MinecraftServer server = MainMod.server;
StringTextComponent succefull = new StringTextComponent(Messages.succefully.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockZ\\}", "" + p.getPositionVec().z).replaceAll("\\{blockX\\}", "" + p.getPositionVec().x).replaceAll("&", "§"));
if(!checkCooldown(p)) {
if(!checkCooldown(p) && !PermissionAPI.hasPermission(p, "randomtp.cooldown.exempt")) {
long secondsLeft = getCooldownLeft(p);
StringTextComponent cooldownmes = new StringTextComponent(Messages.cooldown.get().replaceAll("\\{secondsLeft\\}", Long.toString(secondsLeft)).replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("&", "§"));
p.sendMessage(cooldownmes, p.getUniqueID());
Expand All @@ -68,7 +67,7 @@ private static int runCommand(PlayerEntity p, ServerWorld dim) {
double cal = border.getDiameter()/2;
BigDecimal num = new BigDecimal(cal);
String maxDistance = num.toPlainString();
String dimensionId = dim.func_234923_W_().func_240901_a_().toString();
String dimensionId = dim.getDimensionKey().getRegistryName().toString();
p.setPortal(p.getPosition());
if(!inWhitelist(dimensionId)) {
p.sendMessage(new StringTextComponent(Messages.dimensionNotAllowed.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{dimensionId\\}", dimensionId + "").replace('&', '§')), p.getUniqueID());
Expand All @@ -82,9 +81,11 @@ private static int runCommand(PlayerEntity p, ServerWorld dim) {
}
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());
StringTextComponent succefull = new StringTextComponent(Messages.succefully.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockX\\}", "" + (int)p.getPositionVec().x).replaceAll("\\{blockY\\}", "" + (int)p.getPositionVec().y).replaceAll("\\{blockZ\\}", "" + (int)p.getPositionVec().z).replaceAll("&", "§"));
p.sendMessage(succefull, p.getUniqueID());
} else {
server.getCommandManager().handleCommand(server.getCommandSource(), "spreadplayers " + border.getCenterX() + " " + border.getCenterZ() + " " + Config.min_distance.get() + " " + Config.max_distance.get() + " false " + p.getName().getString().toLowerCase());
StringTextComponent succefull = new StringTextComponent(Messages.succefully.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockX\\}", "" + (int)p.getPositionVec().x).replaceAll("\\{blockY\\}", "" + (int)p.getPositionVec().y).replaceAll("\\{blockZ\\}", "" + (int)p.getPositionVec().z).replaceAll("&", "§"));
p.sendMessage(succefull, p.getUniqueID());
}
cooldowns.put(p.getName().getString(), System.currentTimeMillis());
Expand Down Expand Up @@ -125,7 +126,7 @@ public static boolean inWhitelist(String dimension) {

private static boolean hasPermission(CommandSource source) {
try {
return PermissionAPI.hasPermission(source.asPlayer(), "randomtp.command.basic");
return PermissionAPI.hasPermission(source.asPlayer(), "randomtp.command.interdim");
} catch (CommandSyntaxException e) {
return false;
}
Expand Down Expand Up @@ -155,14 +156,14 @@ private static void randomTeleport(PlayerEntity p) {
maxTries--;
}
if(maxTries == 0) {
StringTextComponent msg = new StringTextComponent("Error, please try again.");
StringTextComponent msg = new StringTextComponent(Messages.maxTries.get().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("&", "§"));
p.sendMessage(msg, p.getUniqueID());
return;
}
}

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

public static ForgeConfigSpec.ConfigValue<Integer> max_distance;
public static ForgeConfigSpec.ConfigValue<Integer> min_distance;

public static ForgeConfigSpec.ConfigValue<Boolean> only_op_basic;
public static ForgeConfigSpec.ConfigValue<Boolean> only_op_dim;


public static ForgeConfigSpec.ConfigValue<Integer> cooldown;
public static ForgeConfigSpec.ConfigValue<Boolean> useOriginal;
public static ForgeConfigSpec.ConfigValue<Integer> maxTries;
Expand Down Expand Up @@ -59,14 +56,5 @@ public static void initConfig(ForgeConfigSpec.Builder config) {
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
.comment("If you want only op players or with the required permission node to execute the basic /rtp command. (Permission node: randomtp.command.basic) [default: true]")
.define("permission.only_op_basic", true);

only_op_dim = config
.comment("If you want only op players or with the required permission node to execute the inter dimension /rtpd command. (Permission node: randomtp.command.interdim) [default: true])")
.define("permission.only_op_dim", true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ public class Messages {
public static ForgeConfigSpec.ConfigValue<String> succefully;
public static ForgeConfigSpec.ConfigValue<String> cooldown;
public static ForgeConfigSpec.ConfigValue<String> dimensionNotAllowed;
public static ForgeConfigSpec.ConfigValue<String> maxTries;

public static void initConfig(ForgeConfigSpec.Builder config) {
config.comment("Configuration file");

succefully = config
.comment("Message that you want to appier when the command is succefully made. [ placeholders: {playerName} {blockZ} {blockY}, color codes: & + letter (example: &c) ] [default: &aSuccefully teleported you to a random location.]")
.define("command.succefully", "&aSuccefully teleported you to a random location.");
.define("command.succefully", "&aYou have been teleported to the coordinates &e{blockX}, {blockY}, {blockZ}&a.");

cooldown = config
.comment("Message that you want to appier when the command is on cooldown. [ placeholders: {playerName}, color codes: & + letter (example: &c) ] [default: &cWait more {secondsLeft} seconds for execute the command again.]")
Expand All @@ -22,5 +23,9 @@ public static void initConfig(ForgeConfigSpec.Builder config) {
dimensionNotAllowed = config
.comment("Message that you want to appier when you execute /rtpd with a dimension that is in the blacklist [ placeholders: {playerName} {dimensionId}, color codes: & + letter (example: &c) ]. [default: &cYou cannot random teleport to that dimension!]")
.define("command.dimensionNotAllowed", "&cYou cannot random teleport to that dimension!");

maxTries = config
.comment("Message that you want to appier when the max tries of finding a safe location is reached [ placeholders: {playerName}, color codes: & + letter (example: &c) ].")
.define("command.max-tries", "&cTimed out trying to find a safe location to warp to.");
}
}

0 comments on commit 25036d7

Please sign in to comment.