Files
src
build.gradle
Code
7 384
src/main/java/com/example/potionforcer/PotionForcer.java
package com.example.potionforcer;
import com.example.potionforcer.commands.PotionForcerCommand;
import com.example.potionforcer.tasks.EffectEnforcementTask;
import com.example.potionforcer.tasks.PotionScanTask;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class PotionForcer extends JavaPlugin {
private boolean enabled = false;
private EffectEnforcementTask effectTask;
private PotionScanTask scanTask;
@Override
public void onEnable() {
this.getCommand("potionforcer").setExecutor(new PotionForcerCommand(this));
this.getLogger().info("PotionForcer loaded. Use /potionforcer enable to start enforcement.");
}
@Override
public void onDisable() {
if (this.enabled) {
this.stopEnforcement();
}
this.getLogger().info("PotionForcer disabled.");
}
public boolean isSystemEnabled() {
return this.enabled;
}
public void startEnforcement() {
if (this.enabled) {
return;
}
this.enabled = true;
this.effectTask = new EffectEnforcementTask(this);
this.effectTask.runTaskTimer(this, 0L, 20L);
this.scanTask = new PotionScanTask(this);
this.scanTask.runTaskTimer(this, 0L, 3L);
Bukkit.broadcastMessage("§a§lPotion Enforcement System ENABLED");
Bukkit.broadcastMessage("§7Strength II and Speed II are now enforced.");
}
public void stopEnforcement() {
if (!this.enabled) {
return;
}
this.enabled = false;
if (this.effectTask != null) {
this.effectTask.cancel();
this.effectTask = null;
}
if (this.scanTask != null) {
this.scanTask.cancel();
this.scanTask = null;
}
Bukkit.broadcastMessage("§c§lPotion Enforcement System DISABLED");
Bukkit.broadcastMessage("§7All enforcement has stopped.");
}
}