Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Achievements to Advancements / Fix 1.15 support #68

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
.idea
*.iml
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public</url>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://ci.herocraftonline.com/plugin/repository/everything</url>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.2.23-SNAPSHOT</version>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<type>jar</type>
<scope>provided</scope>
<optional>true</optional>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/ensifera/animosity/craftirc/CraftIRC.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ public void onEnable() {
} else {
this.hold.put(HoldType.DEATHS, false);
}
if (this.cHold("achievements") > 0) {
this.hold.put(HoldType.ACHIEVEMENTS, true);
this.holdTimer.schedule(new RemoveHoldTask(this, HoldType.ACHIEVEMENTS), this.cHold("achievements"));
if (this.cHold("advancements") > 0) {
this.hold.put(HoldType.ADVANCEMENTS, true);
this.holdTimer.schedule(new RemoveHoldTask(this, HoldType.ADVANCEMENTS), this.cHold("advancements"));
} else {
this.hold.put(HoldType.ACHIEVEMENTS, false);
this.hold.put(HoldType.ADVANCEMENTS, false);
}

if (CraftIRC.this.getServer().getPluginManager().isPluginEnabled("Vault")) {
Expand Down Expand Up @@ -1298,7 +1298,7 @@ public enum HoldType {
KICKS,
BANS,
DEATHS,
ACHIEVEMENTS
ADVANCEMENTS
}

class RemoveHoldTask extends TimerTask {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerAchievementAwardedEvent;
import org.bukkit.event.player.PlayerAdvancementDoneEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
Expand Down Expand Up @@ -173,19 +173,22 @@ public void onPlayerDeath(PlayerDeathEvent event) {
}

@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerAchievement(PlayerAchievementAwardedEvent event) {
if (this.plugin.isHeld(CraftIRC.HoldType.ACHIEVEMENTS)) {
public void onPlayerAdvancement(PlayerAdvancementDoneEvent event) {
if (this.plugin.isHeld(CraftIRC.HoldType.ADVANCEMENTS)) {
return;
}
if (event.getAchievement() == null) {
if (event.getAdvancement() == null) {
return;
}
final RelayedMessage msg = this.plugin.newMsg(this.plugin.getEndPoint(this.plugin.cMinecraftTag()), null, "achievement");
if (msg == null) {
return;
}
if (event.getAdvancement().getKey().getKey().startsWith("recipes/")) {
return;
}
msg.setField("sender", event.getPlayer().getDisplayName());
msg.setField("message", event.getAchievement().name());
msg.setField("message", event.getAdvancement().getKey().getKey());
msg.setField("world", event.getPlayer().getWorld().getName());
msg.setField("realSender", event.getPlayer().getName());
msg.setField("prefix", this.plugin.getPrefix(event.getPlayer()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.bukkit.plugin.Plugin;

import java.util.Set;
import java.util.UUID;

public final class IRCCommandSender implements ConsoleCommandSender {
private final RelayedCommand cmd;
Expand Down Expand Up @@ -76,6 +77,11 @@ public String getName() {
return this.sender.getName();
}

@Override
public Spigot spigot() {
return this.sender.spigot();
}

@Override
public Server getServer() {
return this.sender.getServer();
Expand Down Expand Up @@ -138,6 +144,16 @@ public void sendMessage(String[] messages) {
}
}

@Override
public void sendMessage(UUID uuid, String message) {
sendMessage(message);
}

@Override
public void sendMessage(UUID uuid, String... messages) {
sendMessage(messages);
}

@Override
public void sendRawMessage(String message) {
final RelayedMessage msg = this.cmd.getPlugin().newMsgToTag(this.console, this.cmd.getField("source"), "command-reply");
Expand All @@ -147,6 +163,11 @@ public void sendRawMessage(String message) {
msg.post();
}

@Override
public void sendRawMessage(UUID uuid, String message) {
sendRawMessage(message);
}

@Override
public void setOp(boolean value) {
this.sender.setOp(value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ensifera.animosity.craftirc.libs.com.sk89q.util.config;

import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.reader.UnicodeReader;
Expand Down Expand Up @@ -52,7 +53,7 @@ public Configuration(File file) {
options.setIndent(4);
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);

yaml = new Yaml(new SafeConstructor(), new EmptyNullRepresenter(), options);
yaml = new Yaml(new SafeConstructor(new LoaderOptions()), new EmptyNullRepresenter(), options);

this.file = file;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ensifera.animosity.craftirc.libs.com.sk89q.util.config;

import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.introspector.Property;
import org.yaml.snakeyaml.nodes.CollectionNode;
import org.yaml.snakeyaml.nodes.MappingNode;
Expand All @@ -12,7 +13,7 @@

class EmptyNullRepresenter extends Representer {
public EmptyNullRepresenter() {
super();
super(new DumperOptions());
this.nullRepresenter = new EmptyRepresentNull();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public TrustingSSLSocketFactory() throws SSLException {
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
try {
SSLContext sslContext;
sslContext = SSLContext.getInstance("SSLv3");
sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, new TrustManager[]{new TrustingX509TrustManager()}, null);
factory = sslContext.getSocketFactory();
} catch (NoSuchAlgorithmException nsae) {
Expand Down