Skip to content

Commit

Permalink
Added Freeze Staff (Now fully working)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeNinjaHD committed Feb 21, 2022
1 parent f68e25d commit fc8492e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/leprofi/trolladdon/TrollAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.leprofi.trolladdon.commands.TrollCommand;
import com.leprofi.trolladdon.listener.HitListener;
import com.leprofi.trolladdon.listener.InventoryClickListener;
import com.leprofi.trolladdon.listener.PlayerMoveListener;
import com.leprofi.trolladdon.listener.PlayerStatChangeListener;
import com.leprofi.trolladdon.utils.Metrics;
import de.marcely.bedwars.api.arena.Arena;
Expand All @@ -15,6 +16,7 @@ public final class TrollAddon extends JavaPlugin {
public static String prefix = "§cTrollAddon §8» §7";
public static ArrayList<Arena> trollArenas = new ArrayList<>();
public static ArrayList<String> invisPlayers = new ArrayList<>();
public static ArrayList<String> frozenPlayers = new ArrayList<>();
private static TrollAddon instance;

public TrollAddon() {
Expand Down Expand Up @@ -47,6 +49,7 @@ public void onEnable() {
Bukkit.getPluginManager().registerEvents(new InventoryClickListener(), this);
Bukkit.getPluginManager().registerEvents(new PlayerStatChangeListener(), this);
Bukkit.getPluginManager().registerEvents(new HitListener(), this);
Bukkit.getPluginManager().registerEvents(new PlayerMoveListener(), this);

//Commands
getCommand("troll").setExecutor(new TrollCommand());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
openGUI(player);
}
} else {
player.sendMessage(TrollAddon.prefix + "§cYou do not have the right to use this command!<");
player.sendMessage(TrollAddon.prefix + "§cYou do not have the right to use this command!");
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.leprofi.trolladdon.listener;

import com.leprofi.trolladdon.TrollAddon;
import com.leprofi.trolladdon.utils.Items;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand All @@ -15,7 +16,13 @@ public void onPlayerAttack(EntityDamageByEntityEvent event) {

if(damager.getInventory().getItemInMainHand().equals(Items.getItem("freeze"))) {
if(!target.hasPermission("trolladdon.prevent")) {
target.setFreezeTicks(20 * 5);
TrollAddon.frozenPlayers.add(target.getName());
TrollAddon.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(TrollAddon.getInstance(), new Runnable() {

public void run() {
TrollAddon.frozenPlayers.remove(target.getName());
}
}, 20*5L);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.leprofi.trolladdon.listener;

import com.leprofi.trolladdon.TrollAddon;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;

public class PlayerMoveListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if(TrollAddon.frozenPlayers.contains(player.getName())) {
//Thanks to Metallic 😁

This comment has been minimized.

Copy link
@MetallicGoat

MetallicGoat Feb 21, 2022

No problemo :)

final Location from = event.getFrom();
final Location to = event.getTo();
event.setTo(new Location(to.getWorld(), from.getX(), from.getY(), from.getZ(), to.getYaw(), to.getPitch()));
}
}
}

0 comments on commit fc8492e

Please sign in to comment.