Skip to content

Commit

Permalink
Refactoring and branch updates
Browse files Browse the repository at this point in the history
  • Loading branch information
APickledWalrus committed Jul 23, 2022
1 parent 19ccd57 commit c10ec7d
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 59 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ dependencies {
shadow group: 'org.bstats', name: 'bstats-bukkit', version: '3.0.0'
implementation group: 'io.papermc.paper', name: 'paper-api', version: '1.19-R0.1-SNAPSHOT'
shadow group: 'net.kyori', name: 'adventure-text-minimessage', version: '4.11.0-SNAPSHOT'
shadow group: 'net.kyori', name: 'adventure-platform-bukkit', version: '4.1.0-SNAPSHOT'
shadow group: 'net.kyori', name: 'adventure-text-serializer-plain', version: '4.10.0-SNAPSHOT'
shadow group: 'net.kyori', name: 'adventure-platform-bukkit', version: '4.1.1-SNAPSHOT'
shadow group: 'net.kyori', name: 'adventure-text-serializer-plain', version: '4.11.0-SNAPSHOT'
implementation group: 'org.eclipse.jdt', name: 'org.eclipse.jdt.annotation', version: '2.2.600'
implementation group: 'com.google.code.findbugs', name: 'findbugs', version: '3.0.1'
implementation group: 'com.sk89q.worldguard', name: 'worldguard-legacy', version: '7.0.0-SNAPSHOT'
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/ch/njol/skript/Skript.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
import java.util.zip.ZipFile;

import ch.njol.skript.lang.Section;
import io.skriptlang.skript.chat.ChatRegistration;
import io.skriptlang.skript.chat.util.ComponentHandler;
import org.skriptlang.skript.bukkit.chat.ChatModule;
import org.skriptlang.skript.bukkit.chat.util.ComponentHandler;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bstats.bukkit.Metrics;
Expand Down Expand Up @@ -102,7 +102,6 @@
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionInfo;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.Section;
import ch.njol.skript.lang.SkriptEvent;
import ch.njol.skript.lang.SkriptEventInfo;
import ch.njol.skript.lang.Statement;
Expand Down Expand Up @@ -510,7 +509,7 @@ public void onEnable() {

try {
getAddonInstance().loadClasses("ch.njol.skript", "conditions", "effects", "events", "expressions", "entity", "sections");
new ChatRegistration().register(getAddonInstance()); // TODO remove eventually
new ChatModule().register(getAddonInstance()); // TODO remove eventually
} catch (final Exception e) {
exception(e, "Could not load required .class files: " + e.getLocalizedMessage());
setEnabled(false);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/classes/data/JavaClasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import ch.njol.skript.registrations.Classes;
import ch.njol.util.StringUtils;
import ch.njol.yggdrasil.Fields;
import io.skriptlang.skript.chat.util.ComponentHandler;
import org.skriptlang.skript.bukkit.chat.util.ComponentHandler;
import org.eclipse.jdt.annotation.Nullable;

import java.util.regex.Pattern;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/command/ScriptCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.Set;
import java.util.UUID;

import io.skriptlang.skript.chat.util.ComponentHandler;
import org.skriptlang.skript.bukkit.chat.util.ComponentHandler;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package ch.njol.skript.hooks.chat.expressions;

import io.skriptlang.skript.chat.util.ComponentHandler;
import org.skriptlang.skript.bukkit.chat.util.ComponentHandler;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;
Expand All @@ -32,7 +32,6 @@
import ch.njol.skript.hooks.VaultHook;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.util.Utils;
import ch.njol.util.Kleenean;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ch/njol/skript/lang/VariableString.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import ch.njol.util.StringUtils;
import ch.njol.util.coll.CollectionUtils;
import ch.njol.util.coll.iterator.SingleItemIterator;
import io.skriptlang.skript.chat.elements.ExprColoured;
import io.skriptlang.skript.chat.util.ComponentHandler;
import org.skriptlang.skript.bukkit.chat.elements.ExprColoured;
import org.skriptlang.skript.bukkit.chat.util.ComponentHandler;
import net.kyori.adventure.text.Component;
import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/ch/njol/skript/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import ch.njol.util.StringUtils;
import ch.njol.util.coll.CollectionUtils;
import net.md_5.bungee.api.ChatColor;
import org.skriptlang.skript.bukkit.chat.util.ComponentHandler;

/**
* Utility class.
Expand Down Expand Up @@ -481,7 +482,7 @@ public static String getChatStyle(final String s) {
*
* @param message
* @return message with localised chat styles converted to Minecraft's format
* @deprecated Use {@link io.skriptlang.skript.chat.util.ComponentHandler#toLegacyString(String)}
* @deprecated Use {@link ComponentHandler#toLegacyString(String)}
*/
@Deprecated
public static String replaceChatStyles(final String message) {
Expand Down Expand Up @@ -521,7 +522,7 @@ public String run(final Matcher m) {
*
* @param message
* @return message with english chat styles converted to Minecraft's format
* @deprecated Use {@link io.skriptlang.skript.chat.util.ComponentHandler#toLegacyString(String)}
* @deprecated Use {@link ComponentHandler#toLegacyString(String)}
*/
public static String replaceEnglishChatStyles(final String message) {
if (message.isEmpty())
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/ch/njol/skript/variables/FlatFileStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import io.skriptlang.skript.chat.util.ComponentHandler;
import org.skriptlang.skript.bukkit.chat.util.ComponentHandler;
import org.eclipse.jdt.annotation.Nullable;

import ch.njol.skript.Skript;
Expand All @@ -45,7 +45,6 @@
import ch.njol.skript.util.ExceptionUtils;
import ch.njol.skript.util.FileUtils;
import ch.njol.skript.util.Task;
import ch.njol.skript.util.Utils;
import ch.njol.skript.util.Version;
import ch.njol.util.NotifyingReference;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,23 @@
*
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
package io.skriptlang.skript.chat;
package org.skriptlang.skript.bukkit.chat;

import ch.njol.skript.SkriptAddon;
import ch.njol.skript.classes.ClassInfo;
import ch.njol.skript.classes.Parser;
import ch.njol.skript.lang.ParseContext;
import ch.njol.skript.registrations.Classes;
import ch.njol.skript.registrations.Converters;
import io.skriptlang.skript.chat.util.ComponentHandler;
import org.skriptlang.skript.bukkit.chat.util.ComponentHandler;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.Tag.Argument;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.apache.commons.lang.StringEscapeUtils;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

import static io.skriptlang.skript.chat.util.ComponentHandler.registerPlaceholder;

public class ChatRegistration {
public class ChatModule {

public void register(SkriptAddon addon) {

Expand Down Expand Up @@ -74,41 +70,41 @@ public String toVariableNameString(Component component) {
// Just to initialize it now
ComponentHandler.getAdventure();

registerPlaceholder("dark_cyan", "<dark_aqua>");
registerPlaceholder("dark_turquoise", "<dark_aqua>");
registerPlaceholder("cyan", "<dark_aqua>");
ComponentHandler.registerPlaceholder("dark_cyan", "<dark_aqua>");
ComponentHandler.registerPlaceholder("dark_turquoise", "<dark_aqua>");
ComponentHandler.registerPlaceholder("cyan", "<dark_aqua>");

registerPlaceholder("purple", "<dark_purple>");
ComponentHandler.registerPlaceholder("purple", "<dark_purple>");

registerPlaceholder("dark_yellow", "<gold>");
registerPlaceholder("orange", "<gold>");
ComponentHandler.registerPlaceholder("dark_yellow", "<gold>");
ComponentHandler.registerPlaceholder("orange", "<gold>");

registerPlaceholder("light_grey", "<grey>");
registerPlaceholder("light_gray", "<grey>");
registerPlaceholder("silver", "<grey>");
ComponentHandler.registerPlaceholder("light_grey", "<grey>");
ComponentHandler.registerPlaceholder("light_gray", "<grey>");
ComponentHandler.registerPlaceholder("silver", "<grey>");

registerPlaceholder("dark_silver", "<dark_grey>");
ComponentHandler.registerPlaceholder("dark_silver", "<dark_grey>");

registerPlaceholder("light_blue", "<blue>");
registerPlaceholder("indigo", "<blue>");
ComponentHandler.registerPlaceholder("light_blue", "<blue>");
ComponentHandler.registerPlaceholder("indigo", "<blue>");

registerPlaceholder("light_green", "<green>");
registerPlaceholder("lime_green", "<green>");
registerPlaceholder("lime", "<green>");
ComponentHandler.registerPlaceholder("light_green", "<green>");
ComponentHandler.registerPlaceholder("lime_green", "<green>");
ComponentHandler.registerPlaceholder("lime", "<green>");

registerPlaceholder("light_cyan", "<aqua>");
registerPlaceholder("light_aqua", "<aqua>");
registerPlaceholder("turquoise", "<aqua>");
ComponentHandler.registerPlaceholder("light_cyan", "<aqua>");
ComponentHandler.registerPlaceholder("light_aqua", "<aqua>");
ComponentHandler.registerPlaceholder("turquoise", "<aqua>");

registerPlaceholder("light_red", "<red>");
ComponentHandler.registerPlaceholder("light_red", "<red>");


registerPlaceholder("pink", "<light_purple>");
registerPlaceholder("magenta", "<light_purple>");
ComponentHandler.registerPlaceholder("pink", "<light_purple>");
ComponentHandler.registerPlaceholder("magenta", "<light_purple>");

registerPlaceholder("light_yellow", "<yellow>");
ComponentHandler.registerPlaceholder("light_yellow", "<yellow>");

registerPlaceholder("underline", "<underlined>");
ComponentHandler.registerPlaceholder("underline", "<underlined>");

ComponentHandler.registerResolver(TagResolver.resolver("unicode", (argumentQueue, context) -> {
String unicode = argumentQueue.popOr("A unicode tag must have an argument of the unicode").value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
package io.skriptlang.skript.chat.elements;
package org.skriptlang.skript.bukkit.chat.elements;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
Expand All @@ -29,7 +29,7 @@
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.util.LiteralUtils;
import ch.njol.util.Kleenean;
import io.skriptlang.skript.chat.util.ComponentHandler;
import org.skriptlang.skript.bukkit.chat.util.ComponentHandler;
import net.kyori.adventure.audience.Audience;
import org.bukkit.Bukkit;
import org.bukkit.World;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
package io.skriptlang.skript.chat.elements;
package org.skriptlang.skript.bukkit.chat.elements;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
Expand All @@ -30,7 +30,7 @@
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.util.LiteralUtils;
import ch.njol.util.Kleenean;
import io.skriptlang.skript.chat.util.ComponentHandler;
import org.skriptlang.skript.bukkit.chat.util.ComponentHandler;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
Expand Down Expand Up @@ -61,6 +61,7 @@
})
@RequiredPlugins("Minecraft 1.16.4+ for optional sender")
@Since("1.0, 2.2-dev26 (advanced features), 2.5.2 (optional sender), 2.6 (sending objects)")
// See what might need taken from https://github.com/SkriptLang/Skript/pull/4545
public class EffMessage extends Effect {

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
package io.skriptlang.skript.chat.elements;
package org.skriptlang.skript.bukkit.chat.elements;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
Expand All @@ -28,7 +28,7 @@
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.util.Timespan;
import ch.njol.util.Kleenean;
import io.skriptlang.skript.chat.util.ComponentHandler;
import org.skriptlang.skript.bukkit.chat.util.ComponentHandler;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.title.Title;
import net.kyori.adventure.title.Title.Times;
Expand All @@ -52,6 +52,7 @@
"send subtitle \"Party!\" to all players"
})
@Since("2.3, INSERT VERSION (sending objects)")
// TODO see what might need taken from https://github.com/SkriptLang/Skript/pull/4362
public class EffSendTitle extends Effect {

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
package io.skriptlang.skript.chat.elements;
package org.skriptlang.skript.bukkit.chat.elements;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
Expand All @@ -30,7 +30,7 @@
import ch.njol.skript.lang.VariableString;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import io.skriptlang.skript.chat.util.ComponentHandler;
import org.skriptlang.skript.bukkit.chat.util.ComponentHandler;
import net.kyori.adventure.text.Component;
import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
@NonNullByDefault({DefaultLocation.PARAMETER, DefaultLocation.RETURN_TYPE, DefaultLocation.FIELD})
package io.skriptlang.skript.chat.util;
package org.skriptlang.skript.bukkit.chat.elements;

import org.eclipse.jdt.annotation.DefaultLocation;
import org.eclipse.jdt.annotation.NonNullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
@NonNullByDefault({DefaultLocation.PARAMETER, DefaultLocation.RETURN_TYPE, DefaultLocation.FIELD})
package io.skriptlang.skript.chat;
package org.skriptlang.skript.bukkit.chat;

import org.eclipse.jdt.annotation.DefaultLocation;
import org.eclipse.jdt.annotation.NonNullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
package io.skriptlang.skript.chat.util;
package org.skriptlang.skript.bukkit.chat.util;

import org.eclipse.jdt.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
package io.skriptlang.skript.chat.util;
package org.skriptlang.skript.bukkit.chat.util;

import ch.njol.skript.Skript;
import ch.njol.skript.lang.Expression;
Expand Down Expand Up @@ -318,6 +318,7 @@ public static String toLegacyString(Component component) {
public static BukkitAudiences getAdventure() {
if (adventure == null)
adventure = BukkitAudiences.create(Skript.getInstance());
// TODO we might need to close this ('adventure.close()')
return adventure;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
@NonNullByDefault({DefaultLocation.PARAMETER, DefaultLocation.RETURN_TYPE, DefaultLocation.FIELD})
package io.skriptlang.skript.chat.elements;
package org.skriptlang.skript.bukkit.chat.util;

import org.eclipse.jdt.annotation.DefaultLocation;
import org.eclipse.jdt.annotation.NonNullByDefault;

0 comments on commit c10ec7d

Please sign in to comment.