Skip to content

Commit

Permalink
MC1.15.2-3.1.2 (Forge 1.15.2)
Browse files Browse the repository at this point in the history
This version fixes a lot of bugs with permissions and add some cool mini features. Here is a detailed change-log:
- Added new max tries message
- Added new permission (randomtp.cooldown.exempt) to ignore cooldown [DEFAULT: OP]
- 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 d433ae5 commit 9163b8c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 29 deletions.
2 changes: 1 addition & 1 deletion 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.15.2-3.1.1'
version = 'MC1.15.2-3.1.2'
group = 'com.gmail.picono435.randomtp' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'RandomTP'

Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/gmail/picono435/randomtp/MainMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
@Mod("randomtp")
public class MainMod {

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

public static final String NEW_LINE;

public static Logger logger;
Expand Down Expand Up @@ -71,7 +68,8 @@ public void init(FMLServerStartingEvent event) {

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");
}
}
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.getPositionVector().z).replaceAll("\\{blockX\\}", "" + p.getPositionVector().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);
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);
} 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);
}
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);
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);
} 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, DimensionType 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.getPositionVector().z).replaceAll("\\{blockX\\}", "" + p.getPositionVector().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);
Expand All @@ -82,9 +81,11 @@ private static int runCommand(PlayerEntity p, DimensionType 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);
} 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);
}
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);
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);
} 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 9163b8c

Please sign in to comment.