Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ java {
}

group = 'me.playbosswar.com'
version = '8.13.2'
version = '8.14.0'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -74,7 +74,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer'
version = '8.13.2'
version = '8.14.0'

from components.java
}
Expand Down
4 changes: 2 additions & 2 deletions java17-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ java {


group = 'me.playbosswar.com'
version = '8.13.2'
version = '8.14.0'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -63,7 +63,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer-java17'
version = '8.13.2'
version = '8.14.0'

from components.java
}
Expand Down
4 changes: 2 additions & 2 deletions java21-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ java {


group = 'me.playbosswar.com'
version = '8.13.2'
version = '8.14.0'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -67,7 +67,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer-java21'
version = '8.13.2'
version = '8.14.0'
from components.java
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/playbosswar/com/CommandTimerPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void onEnable() {
updater = new Updater(this);
metrics = new Metrics(CommandTimerPlugin.getPlugin(), 9657);
hooksManager = new HooksManager();
tasksManager = new TasksManager();
tasksManager = new TasksManager(this);
inventoryManager = new InventoryManager(this);
conditionEngineManager = new ConditionEngineManager();
eventsManager = new EventsManager(tasksManager);
Expand Down Expand Up @@ -142,7 +142,7 @@ private void loadMetrics() {
}

public void registerCommands() {
getCommand("commandtimer").setExecutor(new MainCommand());
getCommand("commandtimer").setExecutor(new MainCommand(this));
}

public void loadConfig() {
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/me/playbosswar/com/commands/MainCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
Expand All @@ -24,8 +25,13 @@
import java.util.List;

public class MainCommand implements CommandExecutor {
private final Plugin plugin;
private final LanguageManager languageManager = CommandTimerPlugin.getLanguageManager();

public MainCommand(Plugin plugin) {
this.plugin = plugin;
}

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String s, String[] args) {
if(!PermissionUtils.playerHasSomeAccess(sender)) {
Expand Down Expand Up @@ -103,7 +109,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
pl.getTasksManager().disable();
pl.saveDefaultConfig();

pl.setTasksManager(new TasksManager());
pl.setTasksManager(new TasksManager(plugin));

Messages.sendMessage(sender, CommandTimerPlugin.getLanguageManager().get(LanguageKey.PLUGIN_RELOADED));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import me.playbosswar.com.tasks.TasksManager;
import me.playbosswar.com.utils.Messages;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -74,10 +75,10 @@ public void handleTriggeredEvent(ConditionExtension extension, EventExtension ev
return;
}

Player p = null;
OfflinePlayer p = null;
UUID uuid = findPotentialPlayer(values);
if(uuid != null) {
p = Bukkit.getPlayer(uuid);
p = Bukkit.getOfflinePlayer(uuid);
}

boolean valid = TaskValidationHelpers.processCondition(task.getCondition(), p);
Expand Down Expand Up @@ -137,6 +138,13 @@ private boolean checkSimpleCondition(EventSimpleCondition<?> simpleCondition, Li
return value.getName().equals(expected.getName());
}

if(receivedValue.getType() == Boolean.class) {
Boolean value = (Boolean) receivedValue.getDefaultValue();
Boolean expected = (Boolean) simpleCondition.getValue();

return value.equals(expected);
}

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ public void init(Player player, InventoryContents contents) {
new ConditionMenu(task, condition, onClose).INVENTORY.open(player);
});
}

if(neededValue.getType() == Boolean.class) {
((ConditionParamField<Boolean>) conditionParamField).setValue(!((ConditionParamField<Boolean>) conditionParamField).getValue());
task.storeInstance();
new ConditionMenu(task, condition, onClose).INVENTORY.open(player);
}

});

contents.set(1, i, clickableItem);
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/me/playbosswar/com/tasks/TaskValidationHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import me.playbosswar.com.conditionsengine.validations.ConditionType;
import me.playbosswar.com.conditionsengine.validations.SimpleCondition;
import me.playbosswar.com.utils.Messages;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.jeasy.rules.api.Facts;
Expand All @@ -19,7 +20,7 @@
import java.util.Optional;

public class TaskValidationHelpers {
public static boolean processCondition(Condition topCondition, @Nullable Player p) {
public static boolean processCondition(Condition topCondition, @Nullable OfflinePlayer p) {
ConditionType conditionType = topCondition.getConditionType();
if(conditionType.equals(ConditionType.SIMPLE)) {
return checkSimpleCondition(topCondition.getSimpleCondition(), p);
Expand All @@ -41,7 +42,7 @@ public static boolean processCondition(Condition topCondition, @Nullable Player
return false;
}

private static boolean checkSimpleCondition(SimpleCondition simpleCondition, @Nullable Player p) {
private static boolean checkSimpleCondition(SimpleCondition simpleCondition, @Nullable OfflinePlayer p) {
final ConditionEngineManager conditionEngineManager =
CommandTimerPlugin.getInstance().getConditionEngineManager();
ConditionRule rule = conditionEngineManager.getRule(simpleCondition.getConditionGroup(),
Expand Down Expand Up @@ -90,6 +91,16 @@ private static boolean checkSimpleCondition(SimpleCondition simpleCondition, @Nu
if(neededValue.getType() == World.class) {
facts.put(conditionParamField.getName(), (World) conditionParamField.getValue());
}

if(neededValue.getType() == Boolean.class) {
facts.put(conditionParamField.getName(), (Boolean) conditionParamField.getValue());
}
}
}

for (NeededValue<?> neededValue : neededValues) {
if (facts.get(neededValue.getName()) == null) {
facts.put(neededValue.getName(), neededValue.getDefaultValue());
}
}

Expand Down
Loading