mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 02:25:42 +01:00
Compatibility with Minecraft 1.21
This commit is contained in:
parent
cc48f149fb
commit
6afb92c0de
@ -39,6 +39,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -66,8 +67,11 @@ public class BukkitActionFactory implements ActionFactory, ConversationAbandoned
|
||||
this.plugin = plugin;
|
||||
// Ensure to initialize factory last so that 'this' is fully initialized before it is passed
|
||||
this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
|
||||
.withFirstPrompt(new ActionMenuPrompt(new ConversationContext(plugin, new BukkitFakeConversable(),
|
||||
new HashMap<>()))).withTimeout(3600)
|
||||
.withFirstPrompt(new ActionMenuPrompt(new ConversationContext(plugin, new BukkitFakeConversable() {
|
||||
@Override
|
||||
public void sendRawMessage(@Nullable final UUID uuid, @NotNull final String s) {
|
||||
}
|
||||
}, new HashMap<>()))).withTimeout(3600)
|
||||
.withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -52,8 +53,11 @@ public class BukkitConditionFactory implements ConditionFactory, ConversationAba
|
||||
this.plugin = plugin;
|
||||
// Ensure to initialize factory last so that 'this' is fully initialized before it is passed
|
||||
this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
|
||||
.withFirstPrompt(new ConditionMenuPrompt(new ConversationContext(plugin, new BukkitFakeConversable(),
|
||||
new HashMap<>()))).withTimeout(3600)
|
||||
.withFirstPrompt(new ConditionMenuPrompt(new ConversationContext(plugin, new BukkitFakeConversable() {
|
||||
@Override
|
||||
public void sendRawMessage(@Nullable final UUID uuid, @NotNull final String s) {
|
||||
}
|
||||
}, new HashMap<>()))).withTimeout(3600)
|
||||
.withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -72,8 +73,11 @@ public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedLi
|
||||
this.plugin = plugin;
|
||||
// Ensure to initialize factory last so that 'this' is fully initialized before it is passed
|
||||
this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
|
||||
.withFirstPrompt(new QuestMenuPrompt(new ConversationContext(plugin, new BukkitFakeConversable(),
|
||||
new HashMap<>()))).withTimeout(3600)
|
||||
.withFirstPrompt(new QuestMenuPrompt(new ConversationContext(plugin, new BukkitFakeConversable() {
|
||||
@Override
|
||||
public void sendRawMessage(@Nullable final UUID uuid, @NotNull final String s) {
|
||||
}
|
||||
}, new HashMap<>()))).withTimeout(3600)
|
||||
.withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this);
|
||||
}
|
||||
|
||||
|
@ -19,13 +19,15 @@ import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* For use when creating a new ConversationContext
|
||||
*/
|
||||
public class BukkitFakeConversable implements Conversable {
|
||||
public abstract class BukkitFakeConversable implements Conversable {
|
||||
public String lastSentMessage;
|
||||
public Conversation begunConversation;
|
||||
public Conversation abandonedConverstion;
|
||||
@ -115,5 +117,7 @@ public class BukkitFakeConversable implements Conversable {
|
||||
|
||||
public void setOp(final boolean value) {
|
||||
}
|
||||
|
||||
public abstract void sendRawMessage(@Nullable UUID uuid, @NotNull String s);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.Potion;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -178,9 +177,7 @@ public class BukkitItemUtil {
|
||||
if (Material.getMaterial("LINGERING_POTION") == null) {
|
||||
if (one.getType().equals(Material.POTION)) {
|
||||
// Bukkit version is below 1.9
|
||||
final Potion pot1 = new Potion(one.getDurability());
|
||||
final Potion pot2 = new Potion(two.getDurability());
|
||||
if (!pot1.getType().equals(pot2.getType())) {
|
||||
if (one.getDurability() != two.getDurability()) {
|
||||
return -9;
|
||||
}
|
||||
}
|
||||
@ -698,75 +695,10 @@ public class BukkitItemUtil {
|
||||
if (e.getName().replace("_", "").equalsIgnoreCase(properName.replace("_", ""))) {
|
||||
return e;
|
||||
}
|
||||
if (getEnchantmentFromProperLegacyName(properName) != null) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Enchantment from name as it appears in lang file
|
||||
*
|
||||
* @deprecated Use {@link #getEnchantmentFromProperName(String)}
|
||||
* @param enchant Name to match lang value to
|
||||
* @return Enchantment or null if invalid
|
||||
*/
|
||||
@Deprecated
|
||||
public static Enchantment getEnchantmentFromProperLegacyName(final String enchant) {
|
||||
if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_ARROW_DAMAGE"))) {
|
||||
return Enchantment.ARROW_DAMAGE;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_ARROW_FIRE"))) {
|
||||
return Enchantment.ARROW_FIRE;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_ARROW_INFINITE"))) {
|
||||
return Enchantment.ARROW_INFINITE;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_ARROW_KNOCKBACK"))) {
|
||||
return Enchantment.ARROW_KNOCKBACK;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_DAMAGE_ALL"))) {
|
||||
return Enchantment.DAMAGE_ALL;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_DAMAGE_ARTHROPODS"))) {
|
||||
return Enchantment.DAMAGE_ARTHROPODS;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_DAMAGE_UNDEAD"))) {
|
||||
return Enchantment.DAMAGE_UNDEAD;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_DIG_SPEED"))) {
|
||||
return Enchantment.DIG_SPEED;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_DURABILITY"))) {
|
||||
return Enchantment.DURABILITY;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_FIRE_ASPECT"))) {
|
||||
return Enchantment.FIRE_ASPECT;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_KNOCKBACK"))) {
|
||||
return Enchantment.KNOCKBACK;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_LOOT_BONUS_BLOCKS"))) {
|
||||
return Enchantment.LOOT_BONUS_BLOCKS;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_LOOT_BONUS_MOBS"))) {
|
||||
return Enchantment.LOOT_BONUS_MOBS;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_LUCK"))) {
|
||||
return Enchantment.LOOT_BONUS_MOBS;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_LURE"))) {
|
||||
return Enchantment.LOOT_BONUS_MOBS;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_OXYGEN"))) {
|
||||
return Enchantment.OXYGEN;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_PROTECTION_ENVIRONMENTAL"))) {
|
||||
return Enchantment.PROTECTION_ENVIRONMENTAL;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_PROTECTION_EXPLOSIONS"))) {
|
||||
return Enchantment.PROTECTION_EXPLOSIONS;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_PROTECTION_FALL"))) {
|
||||
return Enchantment.PROTECTION_FALL;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_PROTECTION_FIRE"))) {
|
||||
return Enchantment.PROTECTION_FIRE;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_PROTECTION_PROJECTILE"))) {
|
||||
return Enchantment.PROTECTION_PROJECTILE;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_SILK_TOUCH"))) {
|
||||
return Enchantment.SILK_TOUCH;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_THORNS"))) {
|
||||
return Enchantment.THORNS;
|
||||
} else if (enchant.equalsIgnoreCase(BukkitLang.get("ENCHANTMENT_WATER_WORKER"))) {
|
||||
return Enchantment.WATER_WORKER;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Enchantment getEnchantmentFromPrettyName(String enchant) {
|
||||
if (enchant != null) {
|
||||
if (BukkitMiscUtil.spaceToCapital(enchant) != null) {
|
||||
|
@ -67,12 +67,7 @@ public class BukkitLang {
|
||||
if (player == null) {
|
||||
return get(key);
|
||||
}
|
||||
String locale;
|
||||
try {
|
||||
locale = player.getLocale();
|
||||
} catch (NoSuchMethodError e) {
|
||||
locale = player.spigot().getLocale();
|
||||
}
|
||||
String locale= player.getLocale();
|
||||
final int separator = locale.indexOf("_");
|
||||
if (separator == -1) {
|
||||
return defaultLang.containsKey(key) ? BukkitFormatToken.convertString(player, defaultLang.get(key)) : "NULL";
|
||||
|
Loading…
Reference in New Issue
Block a user