mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 10:05:59 +00:00
kuper kant kode
This commit is contained in:
parent
cf21b8d07e
commit
f989b34ada
@ -1,9 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@ -16,29 +19,34 @@ public class EntityWiper extends FreedomService
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
public List<EntityType> BLACKLIST = Arrays.asList(
|
||||
EntityType.ARMOR_STAND,
|
||||
EntityType.PAINTING,
|
||||
EntityType.BOAT,
|
||||
EntityType.PLAYER,
|
||||
EntityType.LEASH_HITCH,
|
||||
EntityType.ITEM_FRAME
|
||||
);
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
BLACKLIST.addAll(Groups.MOB_TYPES);
|
||||
// Continuous Entity Wiper
|
||||
wiper = new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
if (world.getEntities().size() > 400)
|
||||
{
|
||||
world.getEntities().clear();
|
||||
wipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 0, 1);
|
||||
}.runTaskTimer(plugin, 1L, 300 * 5); // 5 minutes
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
BLACKLIST.removeAll(Groups.MOB_TYPES);
|
||||
wiper.cancel();
|
||||
wiper = null;
|
||||
}
|
||||
@ -52,7 +60,7 @@ public class EntityWiper extends FreedomService
|
||||
{
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
if (!(entity instanceof Player))
|
||||
if (!BLACKLIST.contains(entity.getType()))
|
||||
{
|
||||
entity.remove();
|
||||
removed++;
|
||||
@ -61,18 +69,4 @@ public class EntityWiper extends FreedomService
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
public int wipe(World world)
|
||||
{
|
||||
int removed = 0;
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
if (!(entity instanceof Player))
|
||||
{
|
||||
entity.remove();
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Make a region for an OP.", usage = "/<command> <playername> <name>", aliases = "mor")
|
||||
public class Command_makeopregion extends FreedomCommand
|
||||
{
|
||||
|
||||
final Map<Flag<?>, Object> flags = new HashMap<Flag<?>, Object>() {{
|
||||
put(Flags.BLOCK_PLACE, StateFlag.State.DENY);
|
||||
put(Flags.BLOCK_BREAK, StateFlag.State.DENY);
|
||||
put(Flags.BUILD, StateFlag.State.DENY);
|
||||
put(Flags.PLACE_VEHICLE, StateFlag.State.DENY);
|
||||
put(Flags.DESTROY_VEHICLE, StateFlag.State.DENY);
|
||||
put(Flags.ENTITY_ITEM_FRAME_DESTROY, StateFlag.State.DENY);
|
||||
put(Flags.ENTITY_PAINTING_DESTROY, StateFlag.State.DENY);
|
||||
}};
|
||||
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = args[1];
|
||||
|
||||
LocalSession session = plugin.web.getWorldEditPlugin().getSession(playerSender);
|
||||
|
||||
Region selection = null;
|
||||
|
||||
try
|
||||
{
|
||||
selection = session.getSelection(session.getSelectionWorld());
|
||||
}
|
||||
catch (IncompleteRegionException e)
|
||||
{
|
||||
msg("Please make a WorldEdit selection", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (selection == null)
|
||||
{
|
||||
msg("Please make a WorldEdit selection", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(name, selection.getMinimumPoint(), selection.getMaximumPoint());
|
||||
|
||||
DefaultDomain owners = new DefaultDomain();
|
||||
owners.addPlayer(playerSender.getName());
|
||||
owners.addPlayer(player.getName());
|
||||
region.setOwners(owners);
|
||||
region.setFlags(flags);
|
||||
|
||||
RegionManager regionManager = plugin.wgb.getWorldGuardPlugin().getRegionManager(playerSender.getWorld());
|
||||
|
||||
regionManager.addRegion(region);
|
||||
|
||||
msg("Successfully created the region '" + name + "' for " + player.getName(), ChatColor.GREEN);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Stop playing sounds", usage = "/<command> [sound]")
|
||||
public class Command_stopsound extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
Sound sound = Sound.valueOf(args[0].toUpperCase());
|
||||
if (sound != null)
|
||||
{
|
||||
playerSender.stopSound(sound);
|
||||
msg("Stopped all " + sound.name() + " sounds", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(args[0] + " is not a valid sound.", ChatColor.RED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Sound sound : Sound.values())
|
||||
{
|
||||
playerSender.stopSound(sound);
|
||||
}
|
||||
msg("Stopped all sounds.", ChatColor.GREEN);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return soundList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public List<String> soundList()
|
||||
{
|
||||
List<String> sounds = new ArrayList<>();
|
||||
for (Sound sound : Sound.values())
|
||||
{
|
||||
sounds.add(sound.name());
|
||||
}
|
||||
return sounds;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user