Added ability to add preset random deleports. Versionpush to 1.5.0 dev

This commit is contained in:
Max Lee 2014-07-04 16:19:30 +02:00
parent a6f6fa29db
commit 6d4731ac5c
3 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,14 @@
# Triggered when you use /rtp without any additional paramters
# Just write your command as you would use it ingame here
# Don't use the -p parameter, this will get added automaticly with the senders name/the specified playername
presets:
default: "/rtp 100 1000"
# add more to use /rtp <rtpname>, player needs "randomteleport.default.<rtpname>"
# <rtpname>: "/rtp 1 2"
msg:
search: "§7RandomTeleport searches for a safe place in world {worldname}. . ."
teleport: "§7RandomTeleport teleported you to"
error:
location: "§4Error: §cRandomTeleport could not find a save location!"
cooldown: "§cYou have to wait {cooldown_text}before using this RandomTeleport again!"

View File

@ -1,7 +1,7 @@
name: RandomTeleport name: RandomTeleport
main: de.themoep.bukkit.plugin.RandomTeleport.RandomTeleport main: de.themoep.bukkit.plugin.RandomTeleport.RandomTeleport
softdepend: [WorldGuard,Factions] softdepend: [WorldGuard,Factions]
version: 1.4.11 version: 1.5.0 dev
description: provides a command to teleport the player to a random save location description: provides a command to teleport the player to a random save location
author: Phoenix616 author: Phoenix616
website: http://dev.bukkit.org/bukkit-plugins/randomteleport/ website: http://dev.bukkit.org/bukkit-plugins/randomteleport/
@ -36,3 +36,6 @@ permissions:
randomteleport.stat: randomteleport.stat:
description: Permission for showing the teleport statistic description: Permission for showing the teleport statistic
default: op default: op
randomteleport.presets.default:
description: Gives permission to use the default random teleport
default: op

View File

@ -27,6 +27,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.text.BreakIterator;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Random; import java.util.Random;
@ -114,6 +115,12 @@ public class RandomTeleport extends JavaPlugin implements CommandExecutor {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void onEnable() { public void onEnable() {
saveDefaultConfig();
RandomTeleport.textsearch = this.getConfig().getString("msg.search");
RandomTeleport.textteleport = this.getConfig().getString("msg.teleport");
RandomTeleport.textlocationerror = this.getConfig().getString("msg.error.location");
RandomTeleport.textcooldownerror = this.getConfig().getString("msg.error.cooldown");
cooldown = (HashMap<String, Long>) readMap("cooldown.map"); cooldown = (HashMap<String, Long>) readMap("cooldown.map");
} }
@ -133,7 +140,28 @@ public class RandomTeleport extends JavaPlugin implements CommandExecutor {
int cooldowntime = 0; int cooldowntime = 0;
World world = null; World world = null;
if(args.length == 0 && sender.hasPermission("randomteleport.presets.default")) {
if(this.getConfig().getString("presets.default") != null) {
String defaultcmd = this.getConfig().getString("presets.default").replace("/", "");
defaultcmd = defaultcmd + " -p " + sender.getName();
this.getServer().dispatchCommand(this.getServer().getConsoleSender(),defaultcmd);
return true;
}
}
if(args.length == 1) {
if(sender.hasPermission("randomteleport.presets." + args[0].toLowerCase())) {
if(this.getConfig().getString("presets." + args[0].toLowerCase()) == null) {
sender.sendMessage(ChatColor.RED + "The Random Teleport " + args[0].toLowerCase() + " does not exist!");
return true;
}
String defaultcmd = this.getConfig().getString("presets." + args[0].toLowerCase()).replace("/", "");
defaultcmd = defaultcmd + " -p " + sender.getName();
this.getServer().dispatchCommand(this.getServer().getConsoleSender(),defaultcmd);
return true;
}
}
// analyze the args & get parameter // analyze the args & get parameter
if(args.length == 1 && args[0].equalsIgnoreCase("stat") && sender.hasPermission("randomteleport.stat")) { if(args.length == 1 && args[0].equalsIgnoreCase("stat") && sender.hasPermission("randomteleport.stat")) {