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

Add greeting for new players through /tutorial #88

Closed
wants to merge 87 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
47cd73c
Created TutorialCommand.java
jasonappah Apr 30, 2020
282f4b2
Added /tutorial to plugins.yml
jasonappah Apr 30, 2020
921b9e1
Added tutorial command to PlayerListener.java
jasonappah Apr 30, 2020
00a8ab0
Finished /tutorial command
jasonappah Apr 30, 2020
1f17838
Run /tutorial when new players join
jasonappah Apr 30, 2020
3df48fb
remove extra space in plugin.yml
jasonappah May 1, 2020
b578fee
capitalized name of static array message
jasonappah May 1, 2020
c14b55d
Merge branch 'master' into master
nice6599 May 2, 2020
be30415
Get rid of unused variable player
jasonappah May 3, 2020
baa942f
Moved for loop into if else statement
jasonappah May 3, 2020
9693fb7
Simplified L26
jasonappah May 3, 2020
4003993
Removed extra spaces
jasonappah May 3, 2020
1ca7f94
Merge branch 'master' of https://github.com/jasonappah/HCCore
jasonappah May 3, 2020
c387f45
Merge branch 'master' into master
jasonappah May 9, 2020
0b84b59
Fix autocomplete for second parameter of /stats (#95)
nice6599 May 13, 2020
bcf7496
Exclude AFKed players from the sleep threshold (#92)
harbar20 May 17, 2020
82b3f62
Fix NPEs in SleepListener on player quit (#99)
ifvictr May 21, 2020
f08d5de
Disallow AFK players from sleeping (#98)
ifvictr May 21, 2020
4d68c0a
Make /spawn message clearer (#100)
ifvictr Jun 19, 2020
6c60beb
Upgrade dependencies to 1.16
ifvictr Jul 1, 2020
3adbda6
Download 1.16 Spigot JAR on Travis build
ifvictr Jul 1, 2020
3652094
Fix advancement message colors
ifvictr Jul 1, 2020
bf0a261
Use license's full name [skip ci]
ifvictr Jul 1, 2020
b41ad23
Added /upvote and /downvote (#103)
rfblock Jul 16, 2020
86e8fc5
Change /downvote from aqua to blue (#105)
rfblock Jul 16, 2020
c82c5c4
Added Pigstep to Musicophile (#107)
rfblock Jul 17, 2020
2ca45ed
Show usernames when hovering on player nickname in chat (#108)
rfblock Aug 13, 2020
7617a31
migrate to gradle
hyperupcall Nov 8, 2020
9b50e5e
fix: remove accidentally commited Justfile
hyperupcall Nov 8, 2020
1301bf3
ci: remove maven
hyperupcall Nov 12, 2020
ee941b2
ci: fix travis
hyperupcall Nov 12, 2020
e08d6ce
ci: fix gradle scan
hyperupcall Nov 12, 2020
1b84ebd
ci: travis don't daemonize
hyperupcall Nov 12, 2020
a976c3a
ci: remove gradle scan
hyperupcall Nov 12, 2020
4d2a755
ci: fix java installation
hyperupcall Nov 12, 2020
4e82785
ci: add maven central
hyperupcall Nov 12, 2020
d2b9764
Allow spaces in loc command
wei2gao Apr 15, 2020
81e607e
Use built-in functions for string joining
wei2gao Apr 15, 2020
b8f2342
Delimit location names with underscores
wei2gao Apr 15, 2020
2311e28
Replace argString with locationName
wei2gao Apr 15, 2020
77c942c
Remove getArgAsString, it's not necessary
wei2gao Apr 16, 2020
6bc3b93
Remove space
ifvictr Apr 16, 2020
beba7a9
Location sharing, first implementation attempt
wei2gao Apr 15, 2020
bb1d3b9
Bring up to date with master
wei2gao Apr 17, 2020
4f03437
Location sharing (not well tested)
wei2gao Apr 22, 2020
c8ca4b2
Implement @ifvictr's suggestions
zanedb Nov 9, 2020
898eb4d
docs: add documentation for setting up environment
hyperupcall Nov 6, 2020
fdbd9b7
Fix typos
ifvictr Nov 7, 2020
0f61260
Make heading levels descend by one
ifvictr Nov 7, 2020
8c6dbf2
Replace "l" with vertical bar in usage message
ifvictr Nov 7, 2020
991419f
Update point-of-contact
zanedb Nov 12, 2020
ad0517e
fix: modify SETUP for Gradle
hyperupcall Nov 12, 2020
59e7dd7
Download 1.16.4 server JAR on Travis builds
ifvictr Nov 7, 2020
975b67f
Depend on 1.16.4
ifvictr Nov 7, 2020
39e707b
fix: actually merge properly
hyperupcall Nov 12, 2020
a54de44
Update ping message for new joiners
faisalsayed10 Jun 26, 2021
0a3a163
Remove deploy section as that is broken because of the migration to t…
Jul 5, 2021
c7a1e5b
Added Discord integration
elinicksic May 24, 2021
85d7f64
Update to 1.17
elinicksic Jun 19, 2021
5128823
Fixed build.gradle to include JDA in the jar
elinicksic Jun 20, 2021
0f8cc90
Update the travis for 1.17
elinicksic Jul 6, 2021
8068b72
Added /tutorial to plugins.yml
jasonappah Apr 30, 2020
8e78ea7
Added tutorial command to PlayerListener.java
jasonappah Apr 30, 2020
17396c7
Created TutorialCommand.java
jasonappah Apr 30, 2020
a40c395
Added /tutorial to plugins.yml
jasonappah Apr 30, 2020
d0c0587
Added tutorial command to PlayerListener.java
jasonappah Apr 30, 2020
91f5ead
Finished /tutorial command
jasonappah Apr 30, 2020
50505cd
Run /tutorial when new players join
jasonappah Apr 30, 2020
4d03fb3
capitalized name of static array message
jasonappah May 1, 2020
3dfda39
Get rid of unused variable player
jasonappah May 3, 2020
8aeb7de
Moved for loop into if else statement
jasonappah May 3, 2020
b334808
Simplified L26
jasonappah May 3, 2020
cca345b
Removed extra spaces
jasonappah May 3, 2020
b4de51e
Added /upvote and /downvote (#103)
rfblock Jul 16, 2020
1dfd3e1
Allow spaces in loc command
wei2gao Apr 15, 2020
b463df5
Delimit location names with underscores
wei2gao Apr 15, 2020
2379982
Replace argString with locationName
wei2gao Apr 15, 2020
55b65b4
Remove getArgAsString, it's not necessary
wei2gao Apr 16, 2020
b5be2a1
Added Discord integration
elinicksic May 24, 2021
c642e80
Added /tutorial to plugins.yml
jasonappah Apr 30, 2020
5c20e33
Added tutorial command to PlayerListener.java
jasonappah Apr 30, 2020
5dff6a3
chore: undo accidental version change
jasonappah Jul 6, 2021
a427cf3
chore: merge
jasonappah Jul 6, 2021
db289c2
Update src/main/java/com/hackclub/hccore/commands/TutorialCommand.java
jasonappah Jul 6, 2021
2889df8
chore: remove broken import
jasonappah Jul 6, 2021
6bcde1e
feat+refactor: separate greeting/rules message
jasonappah Jul 14, 2021
6a55070
style: lint and format
jasonappah Jul 14, 2021
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
7 changes: 4 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"label": "Build plugin",
"type": "shell",
"command": "gradle build",
"command": "./gradlew build",
"group": "build",
"presentation": {
"group": "dev"
Expand All @@ -15,7 +15,7 @@
"type": "shell",
"command": "cp",
"args": [
"${workspaceRoot}/target/HCCore.jar",
"${workspaceRoot}/build/libs/HCCore.jar",
"$HOME/server/plugins"
],
"group": "build",
Expand All @@ -33,7 +33,8 @@
"group": {
"kind": "build",
"isDefault": true
}
},
"problemMatcher": []
},
{
"label": "Start server",
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {
implementation 'de.tr7zw:item-nbt-api:2.8.0'
implementation 'net.dv8tion:JDA:4.2.1_265'

compileOnly 'com.comphenix.protocol:ProtocolLib:4.5.1'
implementation 'com.comphenix.protocol:ProtocolLib:4.5.1'
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc:spigot:1.17-R0.1-SNAPSHOT'
}
16 changes: 16 additions & 0 deletions src/main/java/com/hackclub/hccore/HCCorePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@
import com.comphenix.protocol.events.ListenerPriority;
import com.hackclub.hccore.commands.*;
import com.hackclub.hccore.discord.DiscordBot;
import com.hackclub.hccore.commands.AFKCommand;
import com.hackclub.hccore.commands.ColorCommand;
import com.hackclub.hccore.commands.DownvoteCommand;

import com.hackclub.hccore.commands.LocCommand;
import com.hackclub.hccore.commands.NickCommand;
import com.hackclub.hccore.commands.PingCommand;
import com.hackclub.hccore.commands.ShrugCommand;
import com.hackclub.hccore.commands.SpawnCommand;
import com.hackclub.hccore.commands.StatsCommand;
import com.hackclub.hccore.commands.TableflipCommand;
import com.hackclub.hccore.commands.TutorialCommand;

import com.hackclub.hccore.commands.UpvoteCommand;
import com.hackclub.hccore.listeners.AFKListener;
import com.hackclub.hccore.listeners.AdvancementListener;
import com.hackclub.hccore.listeners.BeehiveInteractionListener;
Expand Down Expand Up @@ -70,8 +84,10 @@ public void onEnable() {
this.getCommand("spawn").setExecutor(new SpawnCommand(this));
this.getCommand("stats").setExecutor(new StatsCommand(this));
this.getCommand("tableflip").setExecutor(new TableflipCommand(this));
this.getCommand("tutorial").setExecutor(new TutorialCommand(this));
this.getCommand("upvote").setExecutor(new UpvoteCommand(this));
this.getCommand("discord").setExecutor(new DiscordCommand(this));
this.getCommand("tutorial").setExecutor(new TutorialCommand(this));

// Register event listeners
this.getServer().getPluginManager().registerEvents(new AdvancementListener(this), this);
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/com/hackclub/hccore/commands/DiscordCommand.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
package com.hackclub.hccore.commands;

import com.hackclub.hccore.HCCorePlugin;

import com.comphenix.protocol.PacketType;
import com.hackclub.hccore.HCCorePlugin;
import com.hackclub.hccore.discord.DiscordBot;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;


public class DiscordCommand implements CommandExecutor {
private HCCorePlugin plugin;
private final HCCorePlugin plugin;

public DiscordCommand(HCCorePlugin plugin) {
this.plugin = plugin;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/hackclub/hccore/commands/LocCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String alias, String
sender.sendMessage(ChatColor.RED + "Please specify the location name");
break;
}

if (!data.getSavedLocations().containsKey(locationName)) {
sender.sendMessage(ChatColor.RED + "No location with that name was found");
break;
Expand All @@ -54,7 +54,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String alias, String
ChatColor.GREEN + "Removed " + locationName + " from saved locations");
break;
}
// /loc get <name>
// /loc get <name>
case "get": {
if (args.length < 2) {
sender.sendMessage(ChatColor.RED + "Please specify the location name");
Expand Down Expand Up @@ -175,7 +175,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String alias, String
ChatColor.GREEN + String.format("%s has shared a location: %s (%s)",
player.getName(), locationName, locationString));
recipData.getSavedLocations().put(player.getName() + ":" + locationName,
sendLocation);
sendLocation);

break;
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String alias, String
int distanceFromSpawn =
(int) player.getLocation().distance(player.getWorld().getSpawnLocation());
int allowedRadius =
this.plugin.getConfig().getInt("settings.spawn-command.allowed-radius");;
this.plugin.getConfig().getInt("settings.spawn-command.allowed-radius");
if (distanceFromSpawn > allowedRadius) {
sender.sendMessage(ChatColor.RED + "You need to be within " + allowedRadius
+ " blocks from spawn to use this command. Currently, you’re "
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/hackclub/hccore/commands/StatsCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ private void sendStatistics(CommandSender sender, Player player, Boolean extende

if (extended) {
sender.sendMessage("- Distance by elytra: "
+ toSIPrefix((double) player.getStatistic(Statistic.AVIATE_ONE_CM)) + "m");
+ toSIPrefix(player.getStatistic(Statistic.AVIATE_ONE_CM)) + "m");
sender.sendMessage("- Distance by minecart: "
+ toSIPrefix((double) player.getStatistic(Statistic.MINECART_ONE_CM)) + "m");
+ toSIPrefix(player.getStatistic(Statistic.MINECART_ONE_CM)) + "m");
sender.sendMessage("- Distance by horse: "
+ toSIPrefix((double) player.getStatistic(Statistic.HORSE_ONE_CM)) + "m");
+ toSIPrefix(player.getStatistic(Statistic.HORSE_ONE_CM)) + "m");
sender.sendMessage("- Distance walked: "
+ toSIPrefix((double) player.getStatistic(Statistic.WALK_ONE_CM)) + "m");
+ toSIPrefix(player.getStatistic(Statistic.WALK_ONE_CM)) + "m");
sender.sendMessage("- Damage taken: " + player.getStatistic(Statistic.DAMAGE_TAKEN));
sender.sendMessage("- Damage dealt: " + player.getStatistic(Statistic.DAMAGE_DEALT));
sender.sendMessage("- Times jumped: " + player.getStatistic(Statistic.JUMP));
Expand All @@ -162,7 +162,7 @@ private void sendStatistics(CommandSender sender, Player player, Boolean extende
// converts numbers to their SI prefix laden counterparts
private static String toSIPrefix(double number) {
if (number < 100) {
return String.valueOf(number) + " c";
return number + " c";
} else if (number < 100000) {
number = Math.round(number / 100);
return String.valueOf(number);
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/com/hackclub/hccore/commands/TutorialCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.hackclub.hccore.commands;

import com.hackclub.hccore.HCCorePlugin;
import com.hackclub.hccore.utils.TutorialUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class TutorialCommand implements CommandExecutor {

private final HCCorePlugin plugin;

public TutorialCommand(HCCorePlugin plugin) {
this.plugin = plugin;
}

@Override
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You must be a player to use this");
return true;
} else {
TutorialUtil.send((Player) sender, false);
}

return true;
}
}
5 changes: 3 additions & 2 deletions src/main/java/com/hackclub/hccore/discord/DiscordBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.md_5.bungee.api.chat.hover.content.Text;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;

import org.bukkit.entity.Player;
import org.bukkit.event.*;
import org.bukkit.event.Event;
Expand All @@ -35,9 +36,9 @@

public class DiscordBot extends ListenerAdapter implements Listener {
private JDA jda;
private HCCorePlugin plugin;
private final HCCorePlugin plugin;
private TextChannel channel;
private String prefix;
private final String prefix;

public DiscordBot(HCCorePlugin plugin) {
this.plugin = plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class PlayerAFKStatusChangeEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();

private boolean isAfk;
private final boolean isAfk;

public PlayerAFKStatusChangeEvent(Player player, boolean isAfk) {
super(player);
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/com/hackclub/hccore/listeners/PlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@

import com.hackclub.hccore.HCCorePlugin;
import com.hackclub.hccore.PlayerData;
import com.hackclub.hccore.utils.TutorialUtil;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.event.player.*;

public class PlayerListener implements Listener {
private final HCCorePlugin plugin;
Expand Down Expand Up @@ -87,6 +84,10 @@ public void onPlayerJoin(final PlayerJoinEvent event) {
event.getPlayer().resetTitle();
event.setJoinMessage(ChatColor.YELLOW
+ ChatColor.stripColor(event.getPlayer().getDisplayName()) + " joined the game");

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the indentation here?

if (!event.getPlayer().hasPlayedBefore()) {
TutorialUtil.send(event.getPlayer(), true);
}
}

@EventHandler
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/hackclub/hccore/utils/TutorialUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.hackclub.hccore.utils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

public class TutorialUtil {
public static final String greeting = ChatColor.RED + "Greetings! Welcome to the Hack Club vanilla Minecraft server!";

public static final String[] tutorial = {"Use /nick to set your nick name and /color to set your chat and name colors", ChatColor.RED + "Rules:", "Be nice.", "No griefing or stealing", "No mods that give an unfair advantage", "Follow Hack Club CoC", "If you want to contribute to plugin development head on over to the GitHub: " + ChatColor.RED + "https://github.com/hackclub/HCCore/. ", "Type /tutorial to see this at any time and /discord to join the Discord!" + ChatColor.BLUE + ChatColor.BOLD + "Also check out the modded server - IP: modded-mc.hackclub.com"};

public static void send(Player player, boolean withIntro) {
if (withIntro) {
player.sendMessage(ChatColor.YELLOW + ChatColor.BOLD.toString() + greeting);
}
for (String message : tutorial) {
player.sendMessage(ChatColor.YELLOW + ChatColor.BOLD.toString() + message);
}
}
}
3 changes: 3 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ commands:
discord:
description: Gets the invite link to the Hackclub Minecraft Community Discord server
usage: /discord
tutorial:
description: Greets new users to the server
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix description. the command itself does not greet new users.

I suggest that you include the "greeting" part in a new player event so "greeting" does not message when you run the command again.

usage: /tutorial