mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
I hate PacksGamingHD.
fix tossmob not working, toggle stuff
This commit is contained in:
commit
86cf9dc344
@ -49,73 +49,91 @@ public class Command_toggle extends FreedomCommand
|
||||
msg("- respawnanchors");
|
||||
msg("- autotp");
|
||||
msg("- autoclear");
|
||||
msg("- minecarts");
|
||||
msg("- landmines");
|
||||
msg("- mp44");
|
||||
msg("- tossmob");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("waterplace"))
|
||||
switch (args[0].toLowerCase())
|
||||
{
|
||||
case "waterplace":
|
||||
{
|
||||
toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("frostwalk"))
|
||||
|
||||
case "frostwalk":
|
||||
{
|
||||
toggle("Frost walker enchantment is", ConfigEntry.ALLOW_FROSTWALKER);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("fireplace"))
|
||||
|
||||
case "fireplace":
|
||||
{
|
||||
toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("lavaplace"))
|
||||
|
||||
case "lavaplace":
|
||||
{
|
||||
toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("fluidspread"))
|
||||
|
||||
case "fluidspread":
|
||||
{
|
||||
toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("lavadmg"))
|
||||
|
||||
case "lavadmg":
|
||||
{
|
||||
toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("firespread"))
|
||||
|
||||
case "firespread":
|
||||
{
|
||||
toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD);
|
||||
plugin.gr.setGameRule(GameRuleHandler.GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean());
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("prelog"))
|
||||
|
||||
case "prelog":
|
||||
{
|
||||
toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("lockdown"))
|
||||
|
||||
case "lockdown":
|
||||
{
|
||||
boolean active = !plugin.lp.isLockdownEnabled();
|
||||
plugin.lp.setLockdownEnabled(active);
|
||||
FUtil.adminAction(sender.getName(), (active ? "A" : "De-a") + "ctivating server lockdown", true);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("petprotect"))
|
||||
|
||||
case "petprotect":
|
||||
{
|
||||
toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("entitywipe"))
|
||||
|
||||
case "entitywipe":
|
||||
{
|
||||
toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("firework"))
|
||||
|
||||
case "firework":
|
||||
{
|
||||
toggle("Firework explosion is", ConfigEntry.ALLOW_FIREWORK_EXPLOSION);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("nonuke"))
|
||||
|
||||
case "nonuke":
|
||||
{
|
||||
if (args.length >= 2)
|
||||
{
|
||||
@ -125,8 +143,11 @@ public class Command_toggle extends FreedomCommand
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("The input provided is not a valid integer.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length >= 3)
|
||||
{
|
||||
try
|
||||
@ -135,17 +156,22 @@ public class Command_toggle extends FreedomCommand
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("The input provided is not a valid integer.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
toggle("Nuke monitor is", ConfigEntry.NUKE_MONITOR_ENABLED);
|
||||
|
||||
if (ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
|
||||
{
|
||||
msg("Anti-freecam range is set to " + ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks.");
|
||||
msg("Block throttle rate is set to " + ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds.");
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("explosives"))
|
||||
|
||||
case "explosives":
|
||||
{
|
||||
if (args.length == 2)
|
||||
{
|
||||
@ -159,82 +185,119 @@ public class Command_toggle extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
toggle("Explosions are", ConfigEntry.ALLOW_EXPLOSIONS);
|
||||
|
||||
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
msg("Radius set to " + ConfigEntry.EXPLOSIVE_RADIUS.getDouble());
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("unsafeenchs"))
|
||||
|
||||
case "unsafeenchs":
|
||||
{
|
||||
toggle("Invalid enchantments are", ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS);
|
||||
return true;
|
||||
toggle("Unsafe enchantments are", ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS);
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("bells"))
|
||||
|
||||
case "bells":
|
||||
{
|
||||
toggle("The ringing of bells is", ConfigEntry.ALLOW_BELLS);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("armorstands"))
|
||||
|
||||
case "armorstands":
|
||||
{
|
||||
toggle("The placement of armor stands is", ConfigEntry.ALLOW_ARMOR_STANDS);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("structureblocks"))
|
||||
|
||||
case "structureblocks":
|
||||
{
|
||||
toggle("Structure blocks are", ConfigEntry.ALLOW_STRUCTURE_BLOCKS);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("jigsaws"))
|
||||
|
||||
case "jigsaws":
|
||||
{
|
||||
toggle("Jigsaws are", ConfigEntry.ALLOW_JIGSAWS);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("grindstones"))
|
||||
|
||||
case "grindstones":
|
||||
{
|
||||
toggle("Grindstones are", ConfigEntry.ALLOW_GRINDSTONES);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("jukeboxes"))
|
||||
|
||||
case "jukeboxes":
|
||||
{
|
||||
toggle("Jukeboxes are", ConfigEntry.ALLOW_JUKEBOXES);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("spawners"))
|
||||
|
||||
case "spawners":
|
||||
{
|
||||
toggle("Spawners are", ConfigEntry.ALLOW_SPAWNERS);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("4chan"))
|
||||
|
||||
case "4chan":
|
||||
{
|
||||
toggle("4chan mode is", ConfigEntry.FOURCHAN_ENABLED);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("beehives"))
|
||||
|
||||
case "beehives":
|
||||
{
|
||||
toggle("Beehives are", ConfigEntry.ALLOW_BEEHIVES);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("respawnanchors"))
|
||||
|
||||
case "respawnanchors":
|
||||
{
|
||||
toggle("Respawn anchors are", ConfigEntry.ALLOW_RESPAWN_ANCHORS);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("autotp"))
|
||||
|
||||
case "autotp":
|
||||
{
|
||||
toggle("Teleportation on join is", ConfigEntry.AUTO_TP);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("autoclear"))
|
||||
|
||||
case "autoclear":
|
||||
{
|
||||
toggle("Clearing inventories on join is", ConfigEntry.AUTO_CLEAR);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
||||
case "minecarts":
|
||||
{
|
||||
return false;
|
||||
toggle("Minecarts are", ConfigEntry.ALLOW_MINECARTS);
|
||||
break;
|
||||
}
|
||||
|
||||
case "landmines":
|
||||
{
|
||||
toggle("Landmines are", ConfigEntry.LANDMINES_ENABLED);
|
||||
break;
|
||||
}
|
||||
|
||||
case "mp44":
|
||||
{
|
||||
toggle("MP44 is", ConfigEntry.MP44_ENABLED);
|
||||
break;
|
||||
}
|
||||
|
||||
case "tossmob":
|
||||
{
|
||||
toggle("Tossmob is", ConfigEntry.TOSSMOB_ENABLED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void toggle(final String name, final ConfigEntry entry)
|
||||
@ -245,16 +308,19 @@ public class Command_toggle extends FreedomCommand
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender))
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList(
|
||||
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
|
||||
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs",
|
||||
"bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives",
|
||||
"respawnanchors", "autotp", "autoclear");
|
||||
"respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob");
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
@ -27,12 +30,17 @@ public class Command_tossmob extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FPlayer playerData = plugin.pl.getPlayer(playerSender);
|
||||
|
||||
EntityType type = null;
|
||||
if (args.length >= 1)
|
||||
{
|
||||
if ("off".equals(args[0]))
|
||||
if (args[0].equalsIgnoreCase("off"))
|
||||
{
|
||||
playerData.disableMobThrower();
|
||||
msg("MobThrower is disabled.", ChatColor.GREEN);
|
||||
@ -41,32 +49,29 @@ public class Command_tossmob extends FreedomCommand
|
||||
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (EntityType loop : EntityType.values())
|
||||
{
|
||||
if (loop.isAlive())
|
||||
{
|
||||
sb.append(" ").append(DepreciationAggregator.getName_EntityType(loop));
|
||||
}
|
||||
}
|
||||
msg("Supported mobs: " + sb.toString().trim(), ChatColor.GREEN);
|
||||
msg("Supported mobs: " + getAllMobNames(), ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
for (EntityType loopType : EntityType.values())
|
||||
for (EntityType loop : EntityType.values())
|
||||
{
|
||||
if (DepreciationAggregator.getName_EntityType(loopType).toLowerCase().equalsIgnoreCase(args[0]))
|
||||
if (loop != null && loop.name().equalsIgnoreCase(args[0]))
|
||||
{
|
||||
type = loopType;
|
||||
type = loop;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
msg(args[0] + " is not a supported mob type. Using a pig instead.", ChatColor.RED);
|
||||
msg("By the way, you can type /tossmob list to see all possible mobs.", ChatColor.RED);
|
||||
type = EntityType.PIG;
|
||||
msg("Unknown entity type: " + args[0], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Groups.MOB_TYPES.contains(type))
|
||||
{
|
||||
msg(FUtil.formatName(type.name()) + " is an entity, however it is not a mob.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,8 +82,10 @@ public class Command_tossmob extends FreedomCommand
|
||||
{
|
||||
speed = Double.parseDouble(args[1]);
|
||||
}
|
||||
catch (NumberFormatException nfex)
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("The input provided is not a valid integer.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,12 +99,20 @@ public class Command_tossmob extends FreedomCommand
|
||||
}
|
||||
|
||||
playerData.enableMobThrower(type, speed);
|
||||
msg("MobThrower is enabled. Creature: " + type + " - Speed: " + speed + ".", ChatColor.GREEN);
|
||||
msg("MobThrower is enabled. Mob: " + type + " - Speed: " + speed + ".", ChatColor.GREEN);
|
||||
msg("Left click while holding a " + Material.BONE.toString() + " to throw mobs!", ChatColor.GREEN);
|
||||
msg("Type '/tossmob off' to disable. -By Madgeek1450", ChatColor.GREEN);
|
||||
|
||||
playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.BONE, 1));
|
||||
|
||||
return true;
|
||||
}
|
||||
public static List<String> getAllMobNames()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (EntityType entityType : Groups.MOB_TYPES)
|
||||
{
|
||||
names.add(entityType.name());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
}
|
@ -104,6 +104,7 @@ public class ItemFun extends FreedomService
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Entity entity = event.getRightClicked();
|
||||
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
|
||||
if (player.getInventory().getItemInMainHand().getType().equals(Material.POTATO) || entity.getType().equals(EntityType.PLAYER))
|
||||
{
|
||||
@ -117,12 +118,32 @@ public class ItemFun extends FreedomService
|
||||
player.sendMessage("Stacked " + entity.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (player.getInventory().getItemInMainHand().getType().equals(Material.BONE) || entity.getType().equals(EntityType.PLAYER))
|
||||
{
|
||||
if (!fPlayer.mobThrowerEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Location playerLoc = player.getLocation();
|
||||
Vector direction = playerLoc.getDirection().normalize();
|
||||
|
||||
LivingEntity livingEntity = (LivingEntity)event.getRightClicked();
|
||||
EntityType entityType = livingEntity.getType();
|
||||
if (!(entityType == fPlayer.mobThrowerCreature()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
livingEntity.setVelocity(direction.multiply(fPlayer.mobThrowerSpeed()));
|
||||
fPlayer.enqueueMob(livingEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event)
|
||||
{
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity instanceof Player || !(event.getDamager() instanceof Player))
|
||||
@ -160,24 +181,6 @@ public class ItemFun extends FreedomService
|
||||
|
||||
switch (event.getMaterial())
|
||||
{
|
||||
case BONE:
|
||||
{
|
||||
if (!fPlayer.mobThrowerEnabled())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Location player_pos = player.getLocation();
|
||||
Vector direction = player_pos.getDirection().normalize();
|
||||
|
||||
LivingEntity rezzed_mob = (LivingEntity)player.getWorld().spawnEntity(player_pos.add(direction.multiply(2.0)), fPlayer.mobThrowerCreature());
|
||||
rezzed_mob.setVelocity(direction.multiply(fPlayer.mobThrowerSpeed()));
|
||||
fPlayer.enqueueMob(rezzed_mob);
|
||||
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
|
||||
case GUNPOWDER:
|
||||
{
|
||||
if (!fPlayer.isMP44Armed())
|
||||
|
Loading…
Reference in New Issue
Block a user