freezing, yml messages, and a funny lil command

This commit is contained in:
Super_
2020-11-01 19:06:08 -05:00
parent 2aba16cff2
commit 668488dfd1
21 changed files with 391 additions and 111 deletions

View File

@ -76,7 +76,7 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
Player player = (Player) sender;
PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
if (!plexPlayer.getRankFromString().isAtleast(getLevel()))
if (!plexPlayer.getRankFromString().isAtLeast(getLevel()))
{
//TODO: Enter <insert level> only and higher msg
return true;
@ -91,7 +91,7 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
} else {
Player player = (Player) sender;
PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
if (!plexPlayer.getRankFromString().isAtleast(getLevel()))
if (!plexPlayer.getRankFromString().isAtLeast(getLevel()))
{
//TODO: Enter <insert level> only and higher msg
return true;
@ -111,7 +111,7 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
{
Player player = (Player) sender;
PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
if (plexPlayer.getRankFromString().isAtleast(getLevel()))
if (plexPlayer.getRankFromString().isAtLeast(getLevel()))
{
return onTabComplete(sender, args);
} else {

View File

@ -10,5 +10,5 @@ import java.lang.annotation.RetentionPolicy;
public @interface CommandPermissions
{
Rank level() default Rank.IMPOSTOR;
RequiredCommandSource source();
RequiredCommandSource source() default RequiredCommandSource.ANY;
}

View File

@ -0,0 +1,133 @@
package me.totalfreedom.plex.command.impl;
import me.totalfreedom.plex.cache.PlayerCache;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotations.CommandParameters;
import me.totalfreedom.plex.command.annotations.CommandPermissions;
import me.totalfreedom.plex.command.source.RequiredCommandSource;
import me.totalfreedom.plex.util.PlexUtils;
import me.totalfreedom.plex.world.BlockMapChunkGenerator;
import me.totalfreedom.plex.world.CustomWorld;
import org.bukkit.*;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.*;
@CommandParameters(description = "Subliminal message.")
@CommandPermissions(source = RequiredCommandSource.IN_GAME)
public class FionnCMD extends PlexCommand
{
public static boolean ENABLED = false;
public static Map<Player, Location> LOCATION_CACHE = new HashMap<>();
public FionnCMD()
{
super("fionn");
}
@Override
public void execute(CommandSender sender, String[] args)
{
Player player = (Player) sender;
if (!player.getUniqueId().equals(UUID.fromString("9aa3eda6-c271-440a-a578-a952ee9aee2f")))
{
sender.sendMessage(ChatColor.RED + "You cannot run this command!");
return;
}
String name = "fionn";
LinkedHashMap<Material, Integer> map = new LinkedHashMap<>();
map.put(Material.CRIMSON_NYLIUM, 1);
map.put(Material.BEDROCK, 1);
World fionnWorld = new CustomWorld(name, new BlockMapChunkGenerator(map)).generate();
ENABLED = true;
fionnWorld.setTime(0);
fionnWorld.getBlockAt(0, 5, 0).setType(Material.BARRIER);
Strider fionn = (Strider) fionnWorld.spawnEntity(new Location(fionnWorld, 12, 6, 6, -180, -3), EntityType.STRIDER);
fionn.setCustomNameVisible(true);
fionn.setCustomName(ChatColor.GREEN + "fionn");
fionn.setAI(false);
Enderman elmon = (Enderman) fionnWorld.spawnEntity(new Location(fionnWorld, 12, 6, 0, 0, 18), EntityType.ENDERMAN);
elmon.setCustomNameVisible(true);
elmon.setCustomName(ChatColor.RED + "elmon");
elmon.setInvulnerable(true);
elmon.setAware(false);
elmon.setGravity(true);
// platforms in cage
PlexUtils.setBlocks(new Location(fionnWorld, 10, 5, -2), new Location(fionnWorld, 14, 5, 2), Material.SMOOTH_STONE);
PlexUtils.setBlocks(new Location(fionnWorld, 10, 9, -2), new Location(fionnWorld, 14, 9, 2), Material.SMOOTH_STONE_SLAB);
// iron bars of cage
PlexUtils.setBlocks(new Location(fionnWorld, 10, 8, -2), new Location(fionnWorld, 10, 6, 2), Material.IRON_BARS);
PlexUtils.setBlocks(new Location(fionnWorld, 14, 8, 2), new Location(fionnWorld, 10, 6, 2), Material.IRON_BARS);
PlexUtils.setBlocks(new Location(fionnWorld, 14, 8, 2), new Location(fionnWorld, 14, 6, -2), Material.IRON_BARS);
PlexUtils.setBlocks(new Location(fionnWorld, 10, 8, -2), new Location(fionnWorld, 14, 6, -2), Material.IRON_BARS);
// lava
PlexUtils.setBlocks(new Location(fionnWorld, 10, 1, -2), new Location(fionnWorld, 14, 0, 2), Material.LAVA);
// iron bars of platform
PlexUtils.setBlocks(new Location(fionnWorld, 12, 2, 6), new Location(fionnWorld, 12, 5, 6), Material.IRON_BARS);
// platform
PlexUtils.setBlocks(new Location(fionnWorld, 11, 6, 7), new Location(fionnWorld, 13, 6, 5), Material.SMOOTH_STONE_SLAB);
for (Player p : Bukkit.getOnlinePlayers())
{
p.setInvisible(true);
LOCATION_CACHE.put(p, p.getLocation());
p.teleport(new Location(fionnWorld, 0, 5, 0, -90, 0));
PlayerCache.getPlexPlayer(p.getUniqueId()).setFrozen(true);
}
lateFakeChat("elmon", "fionn! i'm sorry for not being your sex slave...", ChatColor.RED, 20);
lateFakeChat("fionn", "it's too late for that now...", ChatColor.GREEN, 60);
new BukkitRunnable()
{
@Override
public void run()
{
PlexUtils.setBlocks(new Location(fionnWorld, 13, 5, -1), new Location(fionnWorld, 11, 5, 1), Material.AIR);
}
}.runTaskLater(plugin, 100);
new BukkitRunnable()
{
@Override
public void run()
{
fionn.teleport(new Location(fionnWorld, 2.5, 5.5, 0, 90, -10));
}
}.runTaskLater(plugin, 160);
new BukkitRunnable()
{
public void run()
{
fionn.remove();
elmon.remove();
for (Player p : Bukkit.getOnlinePlayers())
{
p.setInvisible(false);
Location location = LOCATION_CACHE.get(p);
if (location != null)
p.teleport(location);
PlayerCache.getPlexPlayer(p.getUniqueId()).setFrozen(false);
}
LOCATION_CACHE.clear();
ENABLED = false;
}
}.runTaskLater(plugin, 200);
}
@Override
public List<String> onTabComplete(CommandSender sender, String[] args)
{
return null;
}
public static void lateFakeChat(String name, String message, ChatColor color, int delay)
{
new BukkitRunnable()
{
public void run()
{
Bukkit.broadcastMessage(color + name + ChatColor.GRAY + ": " + ChatColor.WHITE + message);
}
}.runTaskLater(plugin, delay);
}
}

View File

@ -11,8 +11,10 @@ import org.bukkit.command.CommandSender;
import java.util.Arrays;
import java.util.List;
import static me.totalfreedom.plex.util.PlexUtils.tl;
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
@CommandParameters(usage = "/<command>", aliases = "tst,tast", description = "HELLO")
@CommandParameters(aliases = "tst,tast", description = "HELLO")
public class TestCMD extends PlexCommand
{
public TestCMD() {
@ -20,8 +22,9 @@ public class TestCMD extends PlexCommand
}
@Override
public void execute(CommandSender sender, String[] args) {
sender.sendMessage(plugin.getMessageManager().getMessage("test"));
public void execute(CommandSender sender, String[] args)
{
sender.sendMessage(tl("variableTest", sender.getName()));
}
@Override

View File

@ -0,0 +1,50 @@
package me.totalfreedom.plex.command.impl;
import com.google.common.collect.ImmutableList;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotations.CommandParameters;
import me.totalfreedom.plex.command.annotations.CommandPermissions;
import me.totalfreedom.plex.command.source.RequiredCommandSource;
import me.totalfreedom.plex.rank.enums.Rank;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static me.totalfreedom.plex.util.PlexUtils.tl;
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME)
@CommandParameters(description = "Teleport to a world.", usage = "/<command> <world>")
public class WorldCMD extends PlexCommand
{
public WorldCMD() {
super("world");
}
@Override
public void execute(CommandSender sender, String[] args)
{
Player player = (Player) sender;
World world = Bukkit.getWorld(args[0]);
player.teleport(new Location(world, 0, world.getHighestBlockYAt(0, 0) + 1, 0, 0, 0));
sender.sendMessage(tl("playerWorldTeleport", world.getName()));
}
@Override
public List<String> onTabComplete(CommandSender sender, String[] args)
{
List<String> worlds = new ArrayList<>();
for (World world : Bukkit.getWorlds())
worlds.add(world.getName());
if (args.length == 1)
return worlds;
return ImmutableList.of();
}
}