-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from v4Guard/develop
v4Guard Plugin v1.1.4
- Loading branch information
Showing
12 changed files
with
177 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/io/v4guard/plugin/core/tasks/types/CompletableMCBrandTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.v4guard.plugin.core.tasks.types; | ||
|
||
import io.v4guard.plugin.bungee.v4GuardBungee; | ||
import io.v4guard.plugin.core.tasks.common.CompletableTask; | ||
import io.v4guard.plugin.core.v4GuardCore; | ||
import org.bson.Document; | ||
|
||
import java.util.*; | ||
|
||
public class CompletableMCBrandTask implements CompletableTask { | ||
|
||
private final String taskID; | ||
private final String username; | ||
private final List<String> brands; | ||
|
||
public CompletableMCBrandTask(String username) { | ||
this.username = username; | ||
this.brands = new ArrayList<>(); | ||
this.taskID = UUID.randomUUID().toString(); | ||
v4GuardCore.getInstance().getCompletableTaskManager().getTasks().put(this.taskID, this); | ||
new Timer().schedule(new TimerTask(){ | ||
@Override | ||
public void run() { | ||
complete(); | ||
} | ||
}, 1000L); | ||
} | ||
|
||
@Override | ||
public void complete() { | ||
Document data = new Document(); | ||
data.put("username", username); | ||
data.put("brand", brands); | ||
v4GuardBungee.getCoreInstance().getBackendConnector().getSocket().emit("mc:brand", data.toJson()); | ||
v4GuardCore.getInstance().getCompletableTaskManager().getTasks().remove(taskID); | ||
} | ||
|
||
@Override | ||
public String getTaskID() { | ||
return this.taskID; | ||
} | ||
|
||
public void addData(String brand) { | ||
if(!this.brands.contains(brand)) this.brands.add(brand); | ||
} | ||
|
||
public String getUsername() { | ||
return this.username; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters