3
0
Fork 0

Added timer command, bump to v2.1.2

This commit is contained in:
stijnb1234 2020-09-26 14:30:32 +02:00
parent 30497cd335
commit 3fdf2aff92
3 changed files with 46 additions and 2 deletions

View file

@ -6,7 +6,7 @@
<groupId>nl.SBDeveloper</groupId>
<artifactId>ThemeParkPlus</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>
<packaging>jar</packaging>
<name>ThemeParkPlus</name>

View file

@ -9,8 +9,10 @@ import nl.sbdeveloper.themeparkplus.api.objects.Gate;
import nl.sbdeveloper.themeparkplus.util.ConfigUtil;
import nl.sbdeveloper.themeparkplus.util.Cuboid;
import nl.sbdeveloper.themeparkplus.util.LGUtil;
import nl.sbdeveloper.themeparkplus.util.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
@ -21,6 +23,7 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashMap;
public class TPPCMD implements CommandExecutor {
@ -146,10 +149,47 @@ public class TPPCMD implements CommandExecutor {
return true;
}
return giveFPTicketCommand(sender, args);
} else if (args[0].equalsIgnoreCase("redstonetimer") && (args.length == 6 || args.length == 7)) {
if (!sender.hasPermission("tpp.redstonetimer")) {
sender.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return true;
}
return redstoneTimerCommand(sender, args);
}
return helpCommand(sender);
}
private boolean redstoneTimerCommand(CommandSender sender, String[] args) {
World bworld = Bukkit.getWorld(args[1]);
double bx = Double.parseDouble(args[2]);
double by = Double.parseDouble(args[3]);
double bz = Double.parseDouble(args[4]);
Location loc = new Location(bworld, bx, by, bz);
long onDelayTicks = Long.parseLong(args[5]) * 20L;
long offDelayTicks = args.length == 7 ? Long.parseLong(args[6]) * 20L : 20L;
Block block = loc.getBlock();
Material oldMaterial = block.getType();
byte oldData = block.getData();
Material redstoneMaterial = XMaterial.REDSTONE_BLOCK.parseMaterial();
if (redstoneMaterial == null) throw new IllegalArgumentException("Redstone Material not found.");
Bukkit.getScheduler().scheduleSyncDelayedTask(ThemeParkPlus.getInstance(), () -> {
block.setType(redstoneMaterial);
if (!XMaterial.isNewVersion()) block.getState().setRawData(oldData); //LEGACY
Bukkit.getScheduler().scheduleSyncDelayedTask(ThemeParkPlus.getInstance(), () -> block.setType(oldMaterial), offDelayTicks);
}, onDelayTicks);
HashMap<String, String> replacements = new HashMap<>();
replacements.put("%sec1%", args[5]);
replacements.put("%sec2%", args[6]);
sender.sendMessage(ConfigUtil.getMessage("RedstoneTimer.Started", replacements));
return true;
}
private boolean giveFPTicketCommand(CommandSender sender, String[] args) {
if (args.length == 2 && !(sender instanceof Player)) {
sender.sendMessage(ConfigUtil.getMessage("General.NoPlayer"));
@ -205,6 +245,8 @@ public class TPPCMD implements CommandExecutor {
sender.sendMessage("§6/themeparkplus lampson <World> <X1> <Y1> <Z1> <X2> <Y2> <Z2> [Seconds on]§f: Turn multiple lamps on.");
sender.sendMessage("§6/themeparkplus lampsoff <World> <X1> <Y1> <Z1> <X2> <Y2> <Z2>§f: Turn multiple lamps off.");
sender.sendMessage(" ");
sender.sendMessage("§6/themeparkplus redstonetimer <World> <X> <Y> <Z> <Delay> [Off Delay] §f: Create a Redstone delayer.");
sender.sendMessage(" ");
sender.sendMessage("§6/themeparkplus givefpticket <RideID> [Player]§f: Give yourself or someone else a Fastpass ticket (for free).");
return true;
}

View file

@ -36,3 +36,5 @@ Lamps:
WaitingRow:
SignCreated: '&aYou''ve successfully created a waitingrow sign!'
WrongLocation: '&cA waitingrow sign (from the attraction %ridename%) couldn''t be found! It will be deleted.'
RedstoneTimer:
Started: '&aThe timer successfully started. It will go off in &f%sec1% &asecond(s), and will turn off in &f%sec2% &asecond(s) after that.'