Skip to content

Commit

Permalink
Merge pull request #13 from PQguanfang/dev
Browse files Browse the repository at this point in the history
2.7.3
  • Loading branch information
PQguanfang authored Aug 27, 2023
2 parents 6e93abb + 29bbdcf commit dc96973
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>cn.superiormc</groupId>
<artifactId>MythicTotem</artifactId>
<version>2.6.0</version>
<version>2.7.3</version>
<packaging>jar</packaging>

<name>MythicTotem</name>
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/cn/superiormc/mythictotem/MythicTotem.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import cn.superiormc.mythictotem.events.PlayerClickEvent;
import cn.superiormc.mythictotem.events.PlayerPlaceEvent;
import cn.superiormc.mythictotem.events.TotemRedstoneEvent;
import cn.superiormc.mythictotem.managers.*;
import cn.superiormc.mythictotem.libreforge.TriggerTotemActived;
import cn.superiormc.mythictotem.managers.PlacedBlockCheckManager;
import cn.superiormc.mythictotem.managers.TotemManager;
import cn.superiormc.mythictotem.utils.CheckPluginLoad;
import io.th0rgal.protectionlib.ProtectionLib;
import org.bukkit.Bukkit;
Expand All @@ -26,7 +28,7 @@ public final class MythicTotem extends JavaPlugin {

public static String lastErrorMessage = "";

public static boolean freeVersion = true;
public static boolean freeVersion = false;

public static int threeDtotemAmount = 0;

Expand All @@ -45,6 +47,11 @@ public void onEnable() {
instance = this;
ProtectionLib.init(this);
this.saveDefaultConfig();
if (GeneralSettingConfigs.GetRegisterLibreforge()) {
Bukkit.getConsoleSender().sendMessage("§x§9§8§F§B§9§8[MythicTotem] §fHooking into libreforge...");
TriggerTotemActived.load();
Bukkit.getConsoleSender().sendMessage("§x§9§8§F§B§9§8[MythicTotem] §fRegistered totem_actived trigger for libreforge!");
}
TotemConfigs.GetTotemConfigs();
Events();
Commands();
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/cn/superiormc/mythictotem/api/TotemActivedEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package cn.superiormc.mythictotem.api;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class TotemActivedEvent extends Event {

private static final HandlerList handlers = new HandlerList();

private final Player player;

private final Location location;

private final String totemID;

public TotemActivedEvent(String totemID, Player player, Location location) {
this.player = player;
this.location = location;
this.totemID = totemID;
}

public Player GetPlayer() {
return player;
}

public Location GetLocation() {
return location;
}

public String GetTotemID() {
return totemID;
}

@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}

public static HandlerList getHandlerList() {
return handlers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ public static boolean GetBlockDamageEventCancel(){
return MythicTotem.instance.getConfig().getBoolean("settings.disappear.BlockDamageEvent.enabled", false);
}

public static boolean GetRegisterLibreforge(){
return MythicTotem.instance.getConfig().getBoolean("settings.register-libreforge", false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import cn.superiormc.mythictotem.MythicTotem;
import cn.superiormc.mythictotem.configs.GeneralSettingConfigs;
import cn.superiormc.mythictotem.managers.ValidManager;
import dev.lone.itemsadder.api.CustomBlock;
import io.lumine.mythic.core.items.MythicItem;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -41,7 +39,7 @@ public void InteractEvent(PlayerInteractEvent event) {
}, MythicTotem.instance.getConfig().getLong("settings.cooldown-tick", 5L));
if (MythicTotem.instance.getConfig().getBoolean("settings.debug", false)) {
Bukkit.getConsoleSender().sendMessage("§x§9§8§F§B§9§8[MythicTotem] §eLocation: " + event.getClickedBlock().getLocation());
Bukkit.getConsoleSender().sendMessage("§x§9§8§F§B§9§8[MythicTotem] §bIA Block: " + CustomBlock.byAlreadyPlaced(event.getClickedBlock()).getNamespacedID());
//Bukkit.getConsoleSender().sendMessage("§x§9§8§F§B§9§8[MythicTotem] §bIA Block: " + CustomBlock.byAlreadyPlaced(event.getClickedBlock()).getNamespacedID());
Bukkit.getConsoleSender().sendMessage("§x§9§8§F§B§9§8[MythicTotem] §cBiome: " + event.getClickedBlock().getBiome().name());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ public class TotemRedstoneEvent implements Listener {

@EventHandler
public void RedstoneEvent(BlockRedstoneEvent event) {
if (event.isCancelled()) {
return;
}
Bukkit.getScheduler().runTaskAsynchronously(MythicTotem.instance, () -> {
synchronized(event) {
new ValidManager(event);
}
});
if (MythicTotem.instance.getConfig().getBoolean("settings.debug", false)) {
Bukkit.getConsoleSender().sendMessage("§x§9§8§F§B§9§8[MythicTotem] §eLocation: " + event.getBlock().getLocation());
Bukkit.getConsoleSender().sendMessage("§x§9§8§F§B§9§8[MythicTotem] §bIA Block: " + CustomBlock.byAlreadyPlaced(event.getBlock()).getNamespacedID());
//Bukkit.getConsoleSender().sendMessage("§x§9§8§F§B§9§8[MythicTotem] §bIA Block: " + CustomBlock.byAlreadyPlaced(event.getBlock()).getNamespacedID());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package cn.superiormc.mythictotem.libreforge;

import cn.superiormc.mythictotem.api.TotemActivedEvent;
import com.willfp.libreforge.Holder;
import com.willfp.libreforge.ProvidedHolder;
import com.willfp.libreforge.SimpleProvidedHolder;
import com.willfp.libreforge.triggers.Trigger;
import com.willfp.libreforge.triggers.TriggerData;
import com.willfp.libreforge.triggers.TriggerParameter;
import com.willfp.libreforge.triggers.Triggers;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashSet;
import java.util.Set;

public class TriggerTotemActived extends Trigger {

public static void load() {
Triggers.INSTANCE.register(new TriggerTotemActived());
}

public TriggerTotemActived() {
super("totem_actived");
}


@NotNull
@Override
public Set<TriggerParameter> getParameters() {
Set<TriggerParameter> data = new HashSet<>();
data.add(TriggerParameter.PLAYER);
data.add(TriggerParameter.BLOCK);
data.add(TriggerParameter.LOCATION);
data.add(TriggerParameter.TEXT);
return data;
}

@EventHandler
public void handle(TotemActivedEvent event) {
Player player = event.GetPlayer();
Location location = event.GetLocation();
Block block = location.getBlock();
String text = event.GetTotemID();
ProvidedHolder holder = new ProvidedHolder() {
@NotNull
@Override
public Holder getHolder() {
return null;
}

@Nullable
@Override
public Object getProvider() {
return null;
}

@NotNull
@Override
public Holder component1() {
return null;
}

@Nullable
@Override
public Object component2() {
return null;
}
};
TriggerData data = new TriggerData(holder,
player,
null,
block,
null,
location,
null,
null,
null,
text,
1,
player);
this.dispatch(player, data, null);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package cn.superiormc.mythictotem.managers;

import cn.superiormc.mythictotem.MythicTotem;
import cn.superiormc.mythictotem.api.TotemActivedEvent;
import cn.superiormc.mythictotem.utils.CheckPluginLoad;
import cn.superiormc.mythictotem.utils.CheckProtection;
import cn.superiormc.mythictotem.utils.RemoveBlock;
import dev.lone.itemsadder.api.CustomBlock;
import io.th0rgal.oraxen.api.OraxenBlocks;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockPlaceEvent;
Expand Down Expand Up @@ -543,6 +545,11 @@ private void AfterCheck(PlacedBlockCheckManager singleTotem,
Bukkit.getScheduler().callSyncMethod(MythicTotem.instance, () -> {
ActionManager actionManager = new ActionManager(startLocation, singleTotem, singleTotem.GetTotemManager().GetTotemAction(), player, block);
actionManager.CheckAction();
TotemActivedEvent totemActivedEvent = new TotemActivedEvent(
singleTotem.GetTotemManager().GetSection().getName(),
this.player,
this.block.getLocation());
Bukkit.getPluginManager().callEvent(totemActivedEvent);
return null;
});
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ settings:
can-break: false
can-interact: false
can-use: false
register-libreforge: false
disappear:
BukkitAPI:
# This BukkitAPI option can not be disabled!
Expand Down

0 comments on commit dc96973

Please sign in to comment.