I hate PacksGamingHD.

fix tossmob not working, toggle stuff
This commit is contained in:
Telesphoreo 2020-08-06 16:18:32 -05:00 committed by GitHub
commit 86cf9dc344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 300 additions and 216 deletions

View File

@ -49,192 +49,255 @@ 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())
{
toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE);
return true;
}
else if (args[0].equalsIgnoreCase("frostwalk"))
{
toggle("Frost walker enchantment is", ConfigEntry.ALLOW_FROSTWALKER);
return true;
}
else if (args[0].equalsIgnoreCase("fireplace"))
{
toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE);
return true;
}
else if (args[0].equalsIgnoreCase("lavaplace"))
{
toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE);
return true;
}
else if (args[0].equalsIgnoreCase("fluidspread"))
{
toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD);
return true;
}
else if (args[0].equalsIgnoreCase("lavadmg"))
{
toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE);
return true;
}
else if (args[0].equalsIgnoreCase("firespread"))
{
toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD);
plugin.gr.setGameRule(GameRuleHandler.GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean());
return true;
}
else if (args[0].equalsIgnoreCase("prelog"))
{
toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG);
return true;
}
else if (args[0].equalsIgnoreCase("lockdown"))
{
boolean active = !plugin.lp.isLockdownEnabled();
plugin.lp.setLockdownEnabled(active);
FUtil.adminAction(sender.getName(), (active ? "A" : "De-a") + "ctivating server lockdown", true);
return true;
}
else if (args[0].equalsIgnoreCase("petprotect"))
{
toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT);
return true;
}
else if (args[0].equalsIgnoreCase("entitywipe"))
{
toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE);
return true;
}
else if (args[0].equalsIgnoreCase("firework"))
{
toggle("Firework explosion is", ConfigEntry.ALLOW_FIREWORK_EXPLOSION);
return true;
}
else if (args[0].equalsIgnoreCase("nonuke"))
{
if (args.length >= 2)
case "waterplace":
{
try
{
ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException ex)
{
}
toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE);
break;
}
if (args.length >= 3)
case "frostwalk":
{
try
{
ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
}
catch (NumberFormatException ex)
{
}
toggle("Frost walker enchantment is", ConfigEntry.ALLOW_FROSTWALKER);
break;
}
toggle("Nuke monitor is", ConfigEntry.NUKE_MONITOR_ENABLED);
if (ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
case "fireplace":
{
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.");
toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE);
break;
}
return true;
}
else if (args[0].equalsIgnoreCase("explosives"))
{
if (args.length == 2)
case "lavaplace":
{
try
{
ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException ex)
{
msg("The input provided is not a valid integer.");
return true;
}
toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE);
break;
}
toggle("Explosions are", ConfigEntry.ALLOW_EXPLOSIONS);
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
case "fluidspread":
{
msg("Radius set to " + ConfigEntry.EXPLOSIVE_RADIUS.getDouble());
toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD);
break;
}
case "lavadmg":
{
toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE);
break;
}
case "firespread":
{
toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD);
plugin.gr.setGameRule(GameRuleHandler.GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean());
break;
}
case "prelog":
{
toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG);
break;
}
case "lockdown":
{
boolean active = !plugin.lp.isLockdownEnabled();
plugin.lp.setLockdownEnabled(active);
FUtil.adminAction(sender.getName(), (active ? "A" : "De-a") + "ctivating server lockdown", true);
break;
}
case "petprotect":
{
toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT);
break;
}
case "entitywipe":
{
toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE);
break;
}
case "firework":
{
toggle("Firework explosion is", ConfigEntry.ALLOW_FIREWORK_EXPLOSION);
break;
}
case "nonuke":
{
if (args.length >= 2)
{
try
{
ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException ex)
{
msg("The input provided is not a valid integer.");
return true;
}
}
if (args.length >= 3)
{
try
{
ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
}
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.");
}
break;
}
case "explosives":
{
if (args.length == 2)
{
try
{
ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException ex)
{
msg("The input provided is not a valid integer.");
return true;
}
}
toggle("Explosions are", ConfigEntry.ALLOW_EXPLOSIONS);
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
msg("Radius set to " + ConfigEntry.EXPLOSIVE_RADIUS.getDouble());
}
break;
}
case "unsafeenchs":
{
toggle("Unsafe enchantments are", ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS);
break;
}
case "bells":
{
toggle("The ringing of bells is", ConfigEntry.ALLOW_BELLS);
break;
}
case "armorstands":
{
toggle("The placement of armor stands is", ConfigEntry.ALLOW_ARMOR_STANDS);
break;
}
case "structureblocks":
{
toggle("Structure blocks are", ConfigEntry.ALLOW_STRUCTURE_BLOCKS);
break;
}
case "jigsaws":
{
toggle("Jigsaws are", ConfigEntry.ALLOW_JIGSAWS);
break;
}
case "grindstones":
{
toggle("Grindstones are", ConfigEntry.ALLOW_GRINDSTONES);
break;
}
case "jukeboxes":
{
toggle("Jukeboxes are", ConfigEntry.ALLOW_JUKEBOXES);
break;
}
case "spawners":
{
toggle("Spawners are", ConfigEntry.ALLOW_SPAWNERS);
break;
}
case "4chan":
{
toggle("4chan mode is", ConfigEntry.FOURCHAN_ENABLED);
break;
}
case "beehives":
{
toggle("Beehives are", ConfigEntry.ALLOW_BEEHIVES);
break;
}
case "respawnanchors":
{
toggle("Respawn anchors are", ConfigEntry.ALLOW_RESPAWN_ANCHORS);
break;
}
case "autotp":
{
toggle("Teleportation on join is", ConfigEntry.AUTO_TP);
break;
}
case "autoclear":
{
toggle("Clearing inventories on join is", ConfigEntry.AUTO_CLEAR);
break;
}
case "minecarts":
{
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;
}
else if (args[0].equalsIgnoreCase("unsafeenchs"))
{
toggle("Invalid enchantments are", ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS);
return true;
}
else if (args[0].equalsIgnoreCase("bells"))
{
toggle("The ringing of bells is", ConfigEntry.ALLOW_BELLS);
return true;
}
else if (args[0].equalsIgnoreCase("armorstands"))
{
toggle("The placement of armor stands is", ConfigEntry.ALLOW_ARMOR_STANDS);
return true;
}
else if (args[0].equalsIgnoreCase("structureblocks"))
{
toggle("Structure blocks are", ConfigEntry.ALLOW_STRUCTURE_BLOCKS);
return true;
}
else if (args[0].equalsIgnoreCase("jigsaws"))
{
toggle("Jigsaws are", ConfigEntry.ALLOW_JIGSAWS);
return true;
}
else if (args[0].equalsIgnoreCase("grindstones"))
{
toggle("Grindstones are", ConfigEntry.ALLOW_GRINDSTONES);
return true;
}
else if (args[0].equalsIgnoreCase("jukeboxes"))
{
toggle("Jukeboxes are", ConfigEntry.ALLOW_JUKEBOXES);
return true;
}
else if (args[0].equalsIgnoreCase("spawners"))
{
toggle("Spawners are", ConfigEntry.ALLOW_SPAWNERS);
return true;
}
else if (args[0].equalsIgnoreCase("4chan"))
{
toggle("4chan mode is", ConfigEntry.FOURCHAN_ENABLED);
return true;
}
else if (args[0].equalsIgnoreCase("beehives"))
{
toggle("Beehives are", ConfigEntry.ALLOW_BEEHIVES);
return true;
}
else if (args[0].equalsIgnoreCase("respawnanchors"))
{
toggle("Respawn anchors are", ConfigEntry.ALLOW_RESPAWN_ANCHORS);
return true;
}
else if (args[0].equalsIgnoreCase("autotp"))
{
toggle("Teleportation on join is", ConfigEntry.AUTO_TP);
return true;
}
else if (args[0].equalsIgnoreCase("autoclear"))
{
toggle("Clearing inventories on join is", ConfigEntry.AUTO_CLEAR);
return true;
}
else
{
return false;
}
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();
}
}
}

View File

@ -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);
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;
}
}

View File

@ -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())